Repository navigation
fix(bin): run fm_exec_timed on bash 3.2 without BASHPID - #9
Merged
VasanthAmana merged 1 commit intoOct 5, 2026
Merged
VasanthAmana merged 1 commit into
VasanthAmana merged 1 commit into
Conversation
fm_exec_timed compared its owner against $BASHPID, which stock macOS bash 3.2 does not define, so under set -u every bounded call died with 'BASHPID: unbound variable'. That broke every backlog transition that runs tasks-axi through fm_tasks_axi (spawn's move to In flight, cleanup's close). Recover the calling frame's real pid from a child's $PPID when BASHPID is absent, as fm_current_pid already does, so the owner keeps its bash 4+ meaning in both the main shell and a subshell. Add bash 3.2 regressions that run the production library under /bin/bash and skip with a message where it is not an old bash.
VasanthAmana
force-pushed
the
fm/firstmate-bash32-bashpid-fix
branch
from
October 5, 2026 09:37
ca734ba to
3335f5b
Compare
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
Install a modern bash on this laptop with Homebrew.
That was the immediate remedy chosen for a fault found on 5 Oct 2026 after upstream firstmate was merged into this copy; the recommendation it was chosen from was "install bash, followed by a proper fix sent through the normal PR route so the next macOS user does not hit it". This task is that proper fix.
The fault: on macOS's built-in /bin/bash 3.2.57,
bin/fm-spawn.shlaunched a worker and then failed with "backlog item could not be moved to In flight (bin/fm-timeout-lib.sh: line 224: BASHPID: unbound variable)", removed the task's record, and left the worker's window and local copy to close by hand. Line 224 is[ "$owner" != "$BASHPID" ] || owner=$PPIDinsidefm_exec_timed; bash 3.2 has noBASHPID, so underset -uthe function dies.bin/fm-backlog-transition-lib.sh:347runstasks-axithroughfm_exec_timed, so every backlog transition is affected - spawn's move to In flight and, by the same path, cleanup's close. Other scripts already write${BASHPID:-$$}. The original project (kunchenguid/firstmate) has the same line, andbin/fm-wake-lib.shalready branches onBASH_VERSINFO, so bash 3.2 is meant to work.What Changed
fm_exec_timedinbin/fm-timeout-lib.shno longer reads$BASHPIDdirectly, which is unset on stock macOS bash 3.2 and aborted underset -u("BASHPID: unbound variable"). It now uses${BASHPID:-...}and, whenBASHPIDis missing, recovers the current shell's real pid by exec'ing a throwawayshand reading its$PPID. The owner-pid logic is the same as on bash 4+: a subshell keeps the script as owner, and the main shell falls back to its parent.tests/fm-timeout-lib.test.shadds cases that run the production library under/bin/bashwhen it is older than bash 4. They cover a bounded command called from the main shell and from a subshell, passing through output and exit status, and the subshell-owner behavior. The cases print a skip message on hosts where/bin/bashis not bash 3.x.Risk Assessment
✅ Low: The fix only changes how fm_exec_timed obtains its own pid when BASHPID is unset. Bash 4+ takes the same path as before. The bash 3.2 fallback gives the same value as BASHPID, and the new tests exercise it behaviorally.
Testing
I ran the timeout-library test file on the real macOS /bin/bash 3.2.57. It passes, including new regressions for main-shell and subshell calls, owner-death handling, and a backlog transition that bounds tasks-axi. I also called the base-commit library directly under
set -u, and it fails with "BASHPID: unbound variable" as reported. The fixed library runs the same call cleanly. I did not run bin/fm-spawn.sh or cleanup end to end, and I did not run the full suite.Evidence: timeout-lib test output
Source: timeout-lib test output
Evidence: direct bash 3.2 run of fixed lib
Source: direct bash 3.2 run of fixed lib
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.
bash tests/fm-timeout-lib.test.sh(all cases pass, including the four new bash 3.2 regressions)/bin/bash3.2.57 withset -u: sourced the base-commit library and ranfm_exec_timed 5 1 echo x/bin/bash3.2.57 withset -u: sourced the fixed library and ranfm_exec_timed 5 1 echo main-ok✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.