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>
Adds two-tier linting before the existing docs/SCRIPTS.md regenerate
step:
- bash -n on every changed nomarchy-* script. Catches syntax errors
that would otherwise be discovered at runtime by an unlucky user.
Always fatal.
- shellcheck --severity=error when shellcheck is on PATH. Catches
unquoted-var, use-before-define, missing-shebang, and other
bug-shaped patterns. Only error-level issues block - the long
tail of pre-existing warnings stays as a known cleanup task,
not a commit blocker. Hook silently skips this step when
shellcheck isn't installed (so contributors without it can still
commit).
Catches the class of bug that's bit us repeatedly: a script ships,
the runtime path that exercises the broken line is rare, and the bug
sits latent until a user trips it. Cheaper to catch at commit time.
Caveat: 156 nomarchy-* scripts already have shellcheck warnings
(severity warning/info/style); we deliberately ship around them via
the --severity=error gate. A future per-script audit can dial the
severity up as scripts get cleaned up.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Two detector bugs fixed:
1. grep_includes missed *.lua, *.ini, *.desktop, *.json — so callers in
elephant providers (lua), mako on-button-* hooks (ini), and any future
MimeType-registered URL handlers (.desktop) were invisible. Adding them
reclassifies nomarchy-notification-dismiss and nomarchy-theme-bg-set
from `unused?` to `kept` (true callers in mako/core.ini and the
elephant background_selector lua).
2. The all_refs regex `nomarchy-[a-z0-9][a-z0-9-]+` greedily captured
trailing dashes, producing junk missing-tokens like `nomarchy-pkg-`,
`nomarchy-cmd-`, `nomarchy-restart-`, etc. from glob references like
`for c in nomarchy-pkg-*`. Tightened to require an alphanumeric end
character. Also restricted to grep_includes so the binary tmpfile
path `nomarchy-menu-rows` no longer leaks in.
New .githooks/pre-commit re-runs the generator and stages docs/SCRIPTS.md
whenever a nomarchy-* script changes. Enable per clone with
`git config core.hooksPath .githooks` (now mentioned in docs/AGENT.md).
Net audit shift after regen: unused? scripts 31→29, missing tokens 30→28,
no false-positive prefix tokens remain.