Repository navigation
Conversation
…ataflow stays clean A dynamic printf -v assignment in the sourced library made ShellCheck treat every variable, $! included, as modified in any subshell that sources it, failing the canonical lint partition with SC2031.
1 task
This was referenced Oct 6, 2026
Closed
Owner
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
Fix the Bash 3.2 regression in bin/fm-timeout-lib.sh, filed upstream as #5847. The PR body must contain the line: Closes #5847
Since #5770, fm_exec_timed reads a bare $BASHPID under set -u (bin/fm-timeout-lib.sh:209:${BASHPID:-$ $} form, and #3789 covers Bash 3.2 subshell-ownership semantics. The issue asks to make the owner check Bash 3.2 safe without changing its meaning on Bash 5, with a test that runs fm_exec_timed under /bin/bash 3.2 when available.
[ "$owner" != "$BASHPID" ] || owner=$PPID). Stock macOS Bash 3.2 has no BASHPID, so every caller dies with "BASHPID: unbound variable". In practice bin/fm-spawn.sh on a stock Mac cannot move the backlog item to In flight and aborts, leaving the launched agent window running. The rest of bin/ uses the portableWhat Changed
fm_exec_timed_self_pidtobin/fm-timeout-lib.sh. It returns the current process's own pid, including inside a subshell. It usesBASHPIDwhen it is set. On Bash 3.2, which has noBASHPID, it starts a childshdirectly (not through command substitution) and reads that child's$PPIDfrom a temp file. A command substitution would run in a forked subshell and report the wrong pid.fm_exec_timednow does its owner check against this helper instead of reading a bare$BASHPID. Callers no longer die withBASHPID: unbound variableunderset -uon stock macOS Bash 3.2. On Bash 5 the check means the same thing as before.tests/fm-timeout-lib.test.sh, covering/bin/bash, Homebrew bash and thebashon PATH where each exists:fm_exec_timedunderset -u, both in a subshell and at top level.fm_exec_timed_self_pidagainst the parent pid thatpsreports for a background child. It does this at top level, in subshells, in nested subshells and inside functions, with a PATH that has nosh.$BASHPIDnow use the helper.Closes #5847
🤖 Generated with Claude Code
Risk Assessment
✅ Low: The change is small and bounded. On Bash 5 it still uses BASHPID, so the owner check means the same thing as before. On Bash 3.2 it gets the process's own pid from a child
shstarted directly by that process, which writes its PPID to a temp file, as the user asked in the review-1 fix. That pid is correct at top level, in subshells and in functions. The new tests run under /bin/bash and compare the resolved pid with ps's PPID, so they would catch both the original unbound-variable crash and the previous command-substitution bug.Testing
I ran the targeted fm-timeout-lib test file under both /bin/bash 3.2.57 and Homebrew Bash 5, and all cases pass on both. I then drove the real fm-spawn backlog path, a bounded
tasks-axi startthat moves the item to In flight, under /bin/bash 3.2. The base commit dies with "BASHPID: unbound variable" and the task stays queued. HEAD moves the task to in_flight with status 0. In an adversarial run the owner dies before the watchdog starts, at top level under Bash 3.2. With HEAD the bounded command ended about 2s later, well before its 20s deadline. With the rejected command-substitution form it was still running after 12s, so the check can tell the two apart. There is no UI surface, so the evidence is CLI transcripts. I did not start a full fm-spawn with a live agent window in a lab, because the timeout lib call it depends on was driven directly with the real tasks-axi. The self-pid and Bash 5 regression scenarios were covered only by unit tests, so they are recorded as untested for live validation.Evidence: tasks-axi move to In flight under Bash 3.2: base crashes, fix succeeds
Source: tasks-axi move to In flight under Bash 3.2: base crashes, fix succeeds
Evidence: Owner dies before watchdog starts at top level under Bash 3.2: fix terminates, counterfactual does not
Source: Owner dies before watchdog starts at top level under Bash 3.2: fix terminates, counterfactual does not
Evidence: fm-timeout-lib test file under /bin/bash 3.2 and Homebrew bash 5
Source: fm-timeout-lib test file under /bin/bash 3.2 and Homebrew bash 5
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
bin/fm-timeout-lib.sh:212- On Bash 3.2,self=$(sh -c 'echo $PPID')does not return this process's pid. Bash 3.2 forks a subshell for the command substitution and does not exec the lone simple command inside it, soshreports that throwaway subshell's pid. I checked this on this host's /bin/bash 3.2.57: with$$=95176the form returns 95177, and inside a function it returns yet another pid. Bash 5 happens to exec it and gets the right answer. The result is thatselfnever matchesowneron Bash 3.2. When fm_exec_timed is the shell's own last command (for examplefm_exec_timed 5 1 cmdat top level of fm-spawn.sh),ownerstays$$. Afterexec perl,$$is the watchdog itself, sokill(0, $owner)always succeeds and the documented 'else the shell's parent' owner check is silently disabled. The case it covers, a parent that dies before the watchdog has read getppid(), goes undetected, and the bounded command can run until its deadline instead of starting the grace escalation. The new comment ('ask a child shell for its parent: that is this process') is also false for this form. Fix: use the exec form already used at bin/fm-wake-lib.sh:39,self=$(exec sh -c 'echo $PPID'). I checked on /bin/bash 3.2 that it returns$$at top level and the subshell's own pid inside( ... ). The new test only checks for the absence of 'unbound' and the exit codes, so it cannot see this. A test that asserts which owner is chosen at top level under /bin/bash would catch it (for example, kill the parent shell right after launch and expect the command to be terminated before its deadline).🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
/bin/bash tests/fm-timeout-lib.test.sh(Bash 3.2.57): all 15 cases ok, including the new owner-check and self-pid cases/opt/homebrew/bin/bash tests/fm-timeout-lib.test.sh(Bash 5): all 15 cases okBefore/after run under /bin/bash 3.2 with set -euo pipefail:(fm_exec_timed 10 10 tasks-axi start demo-a1 --file $T/BACKLOG.md)against a real tasks-axi markdown backlog, with base 30ef650 lib vs HEAD libAdversarial run under /bin/bash 3.2: top-levelfm_exec_timed 20 1 ... sleep 300whose parent (the owner) exits before the watchdog reads getppid (perl start delayed by a wrapper). Run once with HEAD and once with a counterfactual using the rejected$(sh -c 'echo $PPID')form✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.