Repository navigation
Conversation
Stock macOS bash 3.2 treats "${arr[@]}" on an empty array as an unbound
variable under set -u. Three Hermes helpers expanded an array that is
legitimately empty:
- fm_hermes_process_matches with empty args and no readable
/proc/<pid>/cmdline (always the case on macOS), which made the tmux
backend refuse lifecycle commands for an endpoint it could not classify.
- fm_hermes_profile_home without a profile, used by spawn and relaunch.
- fm-hermes-hook.sh for the busy verdict, whose turn-ended flag list is
only filled for idle.
Guard each expansion with the ${arr[@]+"${arr[@]}"} idiom and add a
stock-bash regression that drives each one with an empty list, wired into
the macOS stock-bash CI lane.
[Low impact] The PR appears safe to merge. Reviews (2) · Last reviewed commit: "no-mistakes(document): Document stock-Ba..." · Reviewed by Greptile |
|
Speaking as Kun's firstmate: thanks @syarifid. This is a clean fix with a good repro. Under stock macOS Contract-class: restore (my own read). The repo already ships a stock-macOS-Bash compatibility lane and supports macOS, and these are existing default Hermes/tmux paths that broke there. VISION: aligns (it removes a misleading "unattributed endpoint" refusal and turns a field incident into regression coverage). Greptile 5/5, and the coverage guard, repo invariants and the no-mistakes check pass. Waiting on you, one thing: the no-mistakes attestation in the PR body shows the lint step as What happens after that: this PR edits |
|
Thanks for the review. The lint finding is fixed and the PR was re-raised with |
|
Closing as superseded: #8399 landed the same fix (tolerate an empty words array under bash 3.2 set -u in bin/fm-hermes-process-lib.sh). Thanks for the review. |
Intent
The local fix - we can make it better for upstream
Context: the local fix is a one-line change in
bin/fm-hermes-process-lib.sh, applied in a user's home on 2026-11-05 and never upstreamed.On macOS (
/bin/bash3.2.57),bin/fm-control.sh <task> relaunchon a tmux worker refused withbin/fm-hermes-process-lib.sh: line 6: words[@]: unbound variable, thentask <id>'s endpoint reads '' rather than a positively classified state; refusing to send a lifecycle command into an unattributed endpoint.Cause:
bin/backends/tmux.shcallsfm_hermes_process_matches '' "$pid"; macOS has no/proc/<pid>/cmdline, so the function falls back toread -r -a words <<< "", leavingwordsempty, and underset -ubash 3.2 treats"${words[@]}"on an empty array as unbound, sofor word in "${words[@]}"aborts the caller. Introduced by e719d68 (#8084).Repro:
bash -c 'set -u; source bin/fm-hermes-process-lib.sh; fm_hermes_process_matches "" 123'.The local fix changed the loop to
for word in ${words[@]+"${words[@]}"}; do.The improvement proposed for upstream, and approved: the same fix, a regression test that reproduces the failure on macOS's bash 3.2, and a check for any other spot in the scripts with the same empty-list problem, delivered as one pull request to github.com/kunchenguid/firstmate.
What Changed
"${words[@]}","${args[@]}"expansions with the${arr[@]+"${arr[@]}"}form inbin/fm-hermes-process-lib.sh(fm_hermes_process_matches),bin/fm-hermes-lib.sh(fm_hermes_profile_home) andbin/fm-hermes-hook.sh(busy verdict). On stock macOS/bin/bash3.2 underset -u, an empty array is treated as unbound. This aborted the caller, for examplefm-control.sh <task> relaunchon a tmux worker, which callsfm_hermes_process_matches '' "$pid".tests/fm-hermes-harness.test.shcovering process identity with no readable argv, the default profile lookup, and the busy hook's idle-only flag. CI now runs this test withFM_TEST_STOCK_BASH=1under/bin/bashin.github/workflows/ci.yml.docs/verification/hermes.md.Risk Assessment
✅ Low: The change is three guarded empty-array expansions (the original one-line fix plus two sibling sites) with behavior-level regression tests and a stock-Bash CI lane, and I found no wrong-result path or unguarded sibling in the Hermes scripts.
Testing
I ran the user's exact repro under stock /bin/bash 3.2.57. It aborts on the base code with "words[@]: unbound variable" and returns 1 cleanly with the fix. I ran
tests/fm-hermes-harness.test.shin its stock-bash mode against the fixed tree (3 of 3 pass) and against a throwaway copy with the bin changes reverted (fails). I then reverted each of the three fixed files on its own, and each reversal fails exactly its own test. I also drove the real tmux backend'sfm_backend_tmux_agent_stateagainst a live private tmux pane under bash 3.2 withset -u. With the fix it returns a state ("ambiguous"); with the process-lib fix reverted it aborts with the user's error. Separately, the full harness file fails one Linux-only fixture ("NUL argv identity lost"), which needs /proc and fails the same way on the base commit, so I treated it as unrelated. A static sweep of bin for other empty-array sites was not a live run, so it is recorded as untested. I did not drive the fullfm-control.sh relaunchflow or run a Herdr lab, because the failing call is exercised directly through the backend function. No UI is involved, so there are no screenshots.Evidence: Regression test against pre-fix bin files (bash 3.2)
Source: Regression test against pre-fix bin files (bash 3.2)
Evidence: tmux backend agent_state, fixed
Source: tmux backend agent_state, fixed
Evidence: tmux backend agent_state, pre-fix process-lib
Source: tmux backend agent_state, pre-fix process-lib
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
🔧 **Test** - 1 issue found → no changes applied ✅
fm_hermes_process_matches "" 123underset -uon /bin/bash 3.2.57; it returns cleanly instead of abortingwords[@]: unbound variable-parg) throughfm_hermes_profile_homeunder stock bashFM_TEST_STOCK_BASH=1 /bin/bash tests/fm-hermes-harness.test.sh: ok - profile home resolves the default profile without an empty argumentbusy hermes-hooknot ok ... words[@]: unbound variable"${arr[@]}"expansions that could be empty/bin/bash -c 'set -u; source bin/fm-hermes-process-lib.sh; fm_hermes_process_matches "" 123'on HEAD: rc=1, no errorThe same repro against the base-commit lib:words[@]: unbound variable, rc=127FM_TEST_STOCK_BASH=1 /bin/bash tests/fm-hermes-harness.test.shon HEAD: 3/3 okThe same stock-bash test run against HEAD with the three bin/fm-hermes-*.sh files reverted to the base:not ok - empty args with an unreadable pid ... words[@]: unbound variablebash bin/fm-test-run.sh tests/fm-hermes-harness.test.shon HEAD and on the base commitRead-only grep of bin/ for bare"${arr[@]}"expansions, with spot checks of the candidates🔧 No changes applied.
✅ Re-checked - no issues remain.
/bin/bash -c 'set -u; source bin/fm-hermes-process-lib.sh; fm_hermes_process_matches "" 123' (fixed tree vs base copy)FM_TEST_STOCK_BASH=1 /bin/bash bin/fm-test-tap-verify.sh tests/fm-hermes-harness.test.sh (fixed: 3/3 ok)same command on a copy with all three bin files reverted to 14d06b04 (fails)same command with each of fm-hermes-hook.sh, fm-hermes-lib.sh and fm-hermes-process-lib.sh reverted individually (each fails exactly its own test)fm_backend_tmux_agent_state on a live private tmux pane under /bin/bash 3.2 with set -u, fixed vs process-lib revertedbash bin/fm-test-run.sh tests/fm-hermes-harness.test.sh on the fixed tree and on base (the same pre-existing Linux-only /proc fixture fails on both)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
Sweep of
bin/for the same defectScope:
"${array[@]}"expansions underset -uwhere the array can genuinely be empty at runtime on bash 3.2.About 190 sites were triaged; three were reachable empty and are fixed above (
fm_hermes_process_matches,fm_hermes_profile_homewithout a profile, and the busy verdict infm-hermes-hook.sh).Judged safe and left unchanged:
${#arr[@]}guard or early return."${argv[@]:1}"do not trip bash 3.2 on an empty result;"${arr[*]}"on an empty array does, and no reachable site was found.fm_procevent_path_normalizereaches an empty"${normalized[*]}"only for/, which fails the earlier directory-owner check first, and the output is still correct.fm-backlog-receive.shiteratesKEYS, which is empty only for an outbox with no items; the sender never produces one.Known pre-existing failure
On macOS,
tests/fm-hermes-harness.test.shalready fails at "NUL argv identity lost when names/ps args are blind" before and after this change, because that case needs/proc.It is unrelated and untouched; the new cases run before it so a macOS host reaches them.