Repository navigation
fix(bin): default BASHPID so bounded execution works on Bash 3.2 - #2
Merged
Merged
Conversation
fm_exec_timed read $BASHPID with no default while the library runs under
set -u. Bash 3.2 has no BASHPID, so on a host whose only bash is 3.2 -
stock macOS - every call aborted with "BASHPID: unbound variable" before
reaching its watchdog. The repo declares no bash floor, and every other
BASHPID reference in bin/ is already written ${BASHPID:-$$}; this one site
was not, so the single owner of bounded command execution bounded nothing
there and each caller lost its timeout.
Use the Bash 3.2 idiom bin/fm-wake-lib.sh's fm_current_pid already
establishes: exec a child shell whose PPID identifies this frame the way
BASHPID does. Behaviour on Bash 4+ is unchanged, and on 3.2 the owner is
now resolved rather than fatal.
Verified on bash 3.2.57: fm_exec_timed returns the command's own status,
and a command that outruns its bound still reports 124.
Two probes in tests/fm-timeout-lib.test.sh wrote $BASHPID to identify the calling subshell, so under Bash 3.2 the suite aborted on the same unbound variable the library fix removes and could not witness that fix. Use the same child-shell PPID idiom the library now uses; Bash 4+ still reads BASHPID. Verified on bash 3.2.57: bash bin/fm-test-run.sh tests/fm-timeout-lib.test.sh passes all 15 checks (previously failed before reaching the probe).
This was referenced Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Make Firstmate able to launch workers again on a stock macOS host whose only bash is 3.2. Every crewmate or scout spawn on the captain's Mac failed at the backlog transition with 'bin/fm-timeout-lib.sh: line 218: BASHPID: unbound variable' because fm_exec_timed read $BASHPID with no default under set -u; Bash 3.2 has no BASHPID. The captain chose to apply, unchanged, the one-line fix already committed on the MacBook's Firstmate (commit a815c01, 'fix(bin): default BASHPID so bounded execution works on Bash 3.2'), cherry-picked verbatim: it uses the existing bin/fm-wake-lib.sh fm_current_pid idiom, exec a child sh whose PPID identifies the frame when BASHPID is unset, and behaviour on Bash 4+ is unchanged. A second small commit adjusts the two probes in tests/fm-timeout-lib.test.sh that themselves wrote$BASHPID, so the existing suite can run and witness the fix on Bash 3.2 (it aborted before reaching the probe). Scope is deliberately limited to these two commits: no sweep of other BASHPID sites (every other site already uses $ {BASHPID:-$$}), no bash-version floor declaration, no docs change, no extra hardening. Verified locally on bash 3.2.57: fm_exec_timed returns the command's own status, a command that outruns its bound reports 124, and bash bin/fm-test-run.sh tests/fm-timeout-lib.test.sh passes all 15 checks; shellcheck and bin/fm-lint.sh are clean.
What Changed
Risk Assessment
✅ Low: The narrowly scoped change removes the Bash 3.2 unbound-variable failure at the shared execution boundary, preserves Bash 4+ behavior, and updates only the two affected behavioral probes.
Testing
The focused suite, before/after reproduction, status and timeout probes, and isolated real backlog transition passed. Manual setup and assertion issues were resolved. CLI evidence was captured; no real worker was launched, and Bash 4+ was unavailable.
Evidence: Bash 3.2 regression reproduction, corrected statuses, and real backlog transition
Source: Bash 3.2 regression reproduction, corrected statuses, and real backlog transition
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
PATH=/usr/bin:/bin:/usr/sbin:/sbin /bin/bash bin/fm-test-run.sh tests/fm-timeout-lib.test.sh— passed; GNU timeout case skipped because unavailable.Executed the base library under/bin/bash -u: reproducedBASHPID: unbound variable.Executed fixedfm_exec_timedwith stock PATH: preserved command status 7 and returned 124 for an expired bound.Executed realfm_tasks_axi startunder Bash 3.2 against an isolated markdown backlog; verified persisted state throughtasks-axi showasin_flight.Corrected manual verification setup by exposing the existing Node executable, then corrected the assertion to the CLI'sin_flightstate value.Removed temporary fixtures and verifiedgit status --shortwas clean.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.