fix(githooks): skip bash linting on non-bash nomarchy-* scripts
The nomarchy-* prefix is a name convention, not a language guarantee:
nomarchy-haptic-touchpad is Python. Without a shebang filter, the
pre-commit hook would run `bash -n` on it and abort every commit
that touched the Python helper. Filter to scripts whose shebang
matches `bash` before linting; everything else passes through.
Found via the set -e sweep (1e94818) — the survey caught
nomarchy-haptic-touchpad as a "broken" bash script when it was
just non-bash.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,10 @@ changed_scripts=$(git diff --cached --name-only --diff-filter=ACMR \
|
||||
if [[ -n "$changed_scripts" ]]; then
|
||||
while IFS= read -r script; do
|
||||
[[ -f "$script" ]] || continue
|
||||
# Only lint scripts with a bash shebang. nomarchy-* is a name
|
||||
# convention, not a language guarantee — at least one Python helper
|
||||
# ships under the same prefix (nomarchy-haptic-touchpad).
|
||||
head -1 "$script" | grep -qE '^#!.*\bbash\b' || continue
|
||||
if ! bash -n "$script"; then
|
||||
echo "pre-commit: bash syntax error in $script — aborting commit." >&2
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user