`[hooks] exclude_commands` silently ignored for `head`/`tail` rewrites (honored for `cat`)
Environment
- rtk 0.38.0 and 0.44.2 (both reproduce)
- macOS (Darwin 25.5.0, arm64), Homebrew install
- Config:
~/Library/Application Support/rtk/config.toml
Summary
With head and tail listed in [hooks] exclude_commands, the hook engine still rewrites head -N / tail -N to rtk read. The same list entry works for cat (and for ls, find, git diff, docker logs). No warning is emitted — the binary contains warning: invalid exclude_commands pattern / ignoring trivial exclude_commands pattern strings, but nothing is printed for head/tail.
Repro
# config.toml
[hooks]
exclude_commands = ["cat", "head", "tail"]
$ rtk hook check 'cat x.txt'
No rewrite for: cat x.txt # exclusion honored
$ rtk hook check 'head -50 big.log'
rtk read big.log --max-lines 50 # exclusion ignored, no warning
$ rtk hook check 'tail -100 app.log'
rtk read app.log --tail-lines 100 # exclusion ignored, no warning
Also tried as list entries: "read", "rtk read", "head *", "head -50" — none suppress the rewrite.
Expected
Either head/tail in exclude_commands suppresses the rewrite (consistent with cat), or a startup/stderr warning states the pattern is unsupported. Silent partial application makes the config untrustworthy — the operator believes the exclusion is active when it is not.
Why we needed this
We wanted to opt out of the head rewrite because of the --max-lines halving bug (filed separately) while keeping the rest of the hook active. Currently the only workaround is that the head -n N spelling happens not to be rewritten — which is itself an inconsistency (head -N rewritten, head -n N not; tail -n N rewritten).
The --max-lines halving bug referenced above is filed as #3370.
wshm · Automated triage by AI
🔍 Automated Triage
| 🐛 Category | bug |
| 🟡 Priority | medium |
| 🎯 Confidence | 90% |
Summary
exclude_commands config entry works for cat/ls/find/git diff/docker logs but is silently ignored for head/tail rewrites, with no warning printed despite such warnings existing in the binary — fix the exclude matcher to cover head/tail or emit the unsupported-pattern warning.
Triaged automatically by wshm · This is an automated analysis, not a human review.
I'd like to work on this. Fixing [hooks] exclude_commands so head/tail rewrites honor the exclude list (or warn if unsupported), with a regression test.