Problem
Several pre-commit hooks invoke scripts that rely on bash-specific builtins (mapfile) and GNU extensions (sed -i without backup extension). These fail on non-bash shells like zsh, preventing contributors from committing code.
Affected bash-isms
mapfile (bash >= 4.0 builtin)
mapfile does not exist in POSIX sh or zsh. Hooks using it will abort with mapfile: command not found.
sed -i without backup extension (GNU sed extension)
BSD sed (default on macOS) requires sed -i "" with an explicit backup argument. Bare sed -i errors with sed: invalid command code.
Proposed fix
mapfile → while IFS= read -r loop
# Before (bash >= 4.0)
mapfile -t items < <(some_command)
# After (POSIX-compatible)
items=()
while IFS= read -r line; do items+=("$line"); done < <(some_command)
sed -i → backup-then-remove
# Before (GNU sed only)
sed -i "s/old/new/" "$file"
# After (works on both GNU and BSD sed)
sed -i.bak "s/old/new/" "$file" && rm -f "$file.bak"
Both patterns already have precedent in the repo (the sed -i.bak + rm pattern exists in one CI script; a portable sed -i wrapper exists in a release script).
Problem
Several pre-commit hooks invoke scripts that rely on bash-specific builtins (
mapfile) and GNU extensions (sed -iwithout backup extension). These fail on non-bash shells like zsh, preventing contributors from committing code.Affected bash-isms
mapfile(bash >= 4.0 builtin)mapfiledoes not exist in POSIX sh or zsh. Hooks using it will abort withmapfile: command not found.sed -iwithout backup extension (GNU sed extension)BSD
sed(default on macOS) requiressed -i ""with an explicit backup argument. Baresed -ierrors withsed: invalid command code.Proposed fix
mapfile→while IFS= read -rloopsed -i→ backup-then-removeBoth patterns already have precedent in the repo (the
sed -i.bak+rmpattern exists in one CI script; a portablesed -iwrapper exists in a release script).