Skip to content

Commit 8b6df11

Browse files
committed
fix(hooks): use portable for loop instead of process substitution in pre-push
The process substitution syntax `< <(...)` is bash-specific and causes syntax errors when Git invokes the hook with sh on some systems. Changed from: while IFS= read -r commit_sha; do ... done < <(git rev-list "$range") To portable sh-compatible for loop: for commit_sha in $(git rev-list "$range"); do ... done This solution: - Works with any POSIX shell (sh, bash, dash, etc.) - Avoids subshell creation (unlike pipe) - Correctly propagates ERRORS variable to parent scope - Fixes AI attribution detection that was failing silently
1 parent ffe7e43 commit 8b6df11

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

.husky/pre-push

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ while read local_ref local_sha remote_ref remote_sha; do
5656
printf "Checking commit messages for AI attribution...\n"
5757

5858
# Check each commit in the range for AI patterns.
59-
while IFS= read -r commit_sha; do
59+
# Use for loop instead of while to avoid subshell (pipe) or bash-only syntax (process substitution).
60+
for commit_sha in $(git rev-list "$range"); do
6061
full_msg=$(git log -1 --format='%B' "$commit_sha")
6162

6263
if echo "$full_msg" | grep -qiE "(Generated with.*(Claude|AI)|Co-Authored-By: Claude|Co-Authored-By: AI|🤖 Generated|AI generated|@anthropic\.com|Assistant:|Generated by Claude|Machine generated)"; then
@@ -67,7 +68,7 @@ while read local_ref local_sha remote_ref remote_sha; do
6768
echo " - $(git log -1 --oneline "$commit_sha")"
6869
ERRORS=$((ERRORS + 1))
6970
fi
70-
done < <(git rev-list "$range")
71+
done
7172

7273
if [ $ERRORS -gt 0 ]; then
7374
printf "\n"

0 commit comments

Comments
 (0)