Repository navigation
fix(hermes): tolerate empty args under bash 3.2 set -u - #8399
Conversation
[Medium impact] The PR appears safe to merge. Reviews (2) · Last reviewed commit: "fix(hermes): tolerate empty args under b..." · Reviewed by Greptile |
|
Speaking as Kun's firstmate: thank you @fmaggi-cw. The bug is real. On main, What I checked on head Contract class (my read): restore. The repo already supports stock macOS Bash 3.2 (it has a dedicated CI lane), and this only stops a crash on that path. Nothing else changes. One thing blocks this, and it's waiting on you: the required "PR must be raised via no-mistakes" check fails. The body has no no-mistakes FYI: #8384 and #8300 make the same one-line fix. Those two also touch |
ae1465c to
83ee29a
Compare
|
Speaking as Kun's firstmate: thanks @fmaggi-cw for the clean re-raise. Re-checked on head Contract class (my own read): restore. Full suite queued. The maintainer |
|
Speaking as Kun's firstmate: this is merged. Thank you @fmaggi-cw — really appreciate you taking the time on this. |
Intent
Fix a crash in bin/fm-hermes-process-lib.sh: in fm_hermes_process_matches, the loop 'for word in "${words[@]}"; do' aborts with 'words[@]: unbound variable' under set -u on macOS's default bash 3.2 when the args string is empty (words is an empty array). The fix changes only that loop to 'for word in ${words[@]+"${words[@]}"}; do', and adds one regression test in the existing hermes test suite that calls the function with an empty args string under set -u and passes under /bin/bash 3.2 (it failed before the fix). Nothing else is in scope. This branch already has open PR #8399 against kunchenguid/firstmate main from the fork fmaggi-cw/firstmate; the maintainer confirmed the fix and asked only that it be re-raised through no-mistakes so the PR body carries the structured Pipeline attestation bound to the head. Change no code beyond what the pipeline's own fix rounds require; keep the existing PR title and narrative.
What Changed
fm_hermes_process_matchesinbin/fm-hermes-process-lib.shnow loops over${words[@]+"${words[@]}"}. Underset -u, macOS's bash 3.2 treats an empty array expansion as an unbound variable, so an empty args string used to abort the caller withwords[@]: unbound variable. Now that case expands to nothing on every bash version and the function returns non-zero.tests/fm-hermes-harness.test.shadds a regression assertion: callingfm_hermes_process_matches ''must return non-zero instead of crashing. Under/bin/bash(3.2.57) the suite fails at this point before the fix and gets past it after.Risk Assessment
✅ Low: The change is a one-line bash 3.2 empty-array expansion guard and does not change behavior for non-empty input. It also covers the empty /proc cmdline path. It comes with a behavioral regression test that runs under the suite's set -u, and the diff matches the stated intent exactly.
Testing
I sourced the library directly under set -u with macOS /bin/bash 3.2.57. Empty and whitespace-only args crashed with 'words[@]: unbound variable' on the base library. With the fix they return 1 (no match), and the matching results for real hermes, node TUI, and python -m invocations are unchanged. I also ran the hermes test suite under /bin/bash with the base and fixed libraries. With the base library it aborts at the new empty-args assertion; with the fix it gets past it. On this Mac the suite then stops at a later 'NUL argv identity' assertion that reads /proc/<pid>/cmdline. That assertion fails the same way at base, so the failure comes from the platform, not this change. Evidence is a CLI transcript; there is no UI surface./bin/bash tests/fm-hermes-harness.test.shwith the base lib aborts with 'words[@]: unbound variable' at the new line; with the fixed lib it continues past itEvidence: Empty-args before/after transcript on /bin/bash 3.2
Source: Empty-args before/after transcript on /bin/bash 3.2
AFTER: [] rc=1, [ ] rc=1, [hermes] rc=0, [python3 -m tui_gateway.entry] rc=0, [node -e hermes] rc=1 BEFORE: [] old-lib.sh: line 6: words[@]: unbound variablePipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
tests/fm-hermes-harness.test.sh:47- On macOS the full hermes suite still stops at 'NUL argv identity lost when names/ps args are blind' because that assertion reads /proc/<pid>/cmdline, which macOS doesn't have. It fails the same way on base bf0f346, so this change didn't cause it, and fixing it is outside the requested scope. Linux CI covers it./bin/bash tests/fm-hermes-harness.test.shwith the base lib aborts with 'words[@]: unbound variable' at the new line; with the fixed lib it continues past it/bin/bash -c 'set -u; . bin/fm-hermes-process-lib.sh; fm_hermes_process_matches "$1"'with args '', ' ', hermes, '/usr/local/bin/hermes chat', node ui-tui entry.js, 'python3 -m tui_gateway.entry', 'node -e hermes', vim (HEAD)Same probes with the base bf0f3468 copy of bin/fm-hermes-process-lib.sh, to reproduce the crash/bin/bash tests/fm-hermes-harness.test.shat HEAD and with the base lib swapped in (restored afterwards)/bin/bash tests/fm-hermes-harness.test.shin a temporary worktree at base bf0f3468 (removed afterwards)fm_agent_process_classify(real caller) with empty and hermes args under set -u on /bin/bash 3.2✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.