Repository navigation
Conversation
… the root PR kunchenguid#173 worked around bash 3.2's here-doc-inside-$(...) quote-tracking bug in fm-brief.sh by rewording the one DOD line that happened to trip it, leaving the fragile VAR=$(cat <<EOF ... EOF) pattern in place in four spots. Any future apostrophe added to those bodies breaks `bash -n` on the whole script again. Wrap each heredoc in a local function and capture its stdout instead (DOD=$(dod_text)), which keeps the heredoc lexically outside any $(...) and is immune to the bug regardless of body content. Output is byte-identical across ship (all three delivery modes), scout, --herdr-lab, and secondmate scaffolds - verified by diffing against the pre-fix scaffolds. bin/fm-spawn.sh's batch-dispatch shared_args[@] expansion was already fixed by kunchenguid#173 with the portable ${arr[@]+"${arr[@]}"} idiom; confirmed clean under stock macOS Bash 3.2.57 today. Extended the macos-stock-bash CI job (added in kunchenguid#578) to cover both scripts going forward: bash -n on each, plus the existing tests/fm-brief.test.sh and tests/fm-spawn-batch.test.sh suites, so this class of regression is caught on real stock Bash instead of only the Linux runners' modern bash.
Owner
|
Speaking as Kun's firstmate: closing this as stale. It has been waiting on a contributor update for 14+ days with no author push or comment. Reopen if you want to pick it back up. |
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.
Summary
bin/fm-brief.shhad fourVAR=$(cat <<EOF ... EOF)heredoc-in-command-substitution sites. Bash 3.2's lexer loses quote-tracking through a heredoc body nested inside$(...), so a single unescaped apostrophe anywhere in that text breaks parsing of the entire rest of the script (bash -nfails). PR fix(brief): remove apostrophe breaking bash -n and guard bash 3.2 set -u in spawn #173 previously worked around this by rewording the one sentence that happened to trip it, leaving the fragile pattern in place at all four sites. This PR fixes the root cause: each heredoc is now defined inside a small local function whose stdout is captured instead (DOD=$(dod_text)), keeping the heredoc lexically outside any$(...)and making it structurally immune to the bug regardless of body content.bin/fm-spawn.sh's batch-dispatchshared_args[@]expansion was already fixed by the same prior PR (fix(brief): remove apostrophe breaking bash -n and guard bash 3.2 set -u in spawn #173) with the portable${shared_args[@]+"${shared_args[@]}"}idiom. No code change needed there; verified clean under stock macOS Bash 3.2.57.macos-stock-bashCI job (added in fix: restore fleet snapshots on stock macOS Bash #578) to cover both scripts going forward:bash -non each, plus runningtests/fm-brief.test.shandtests/fm-spawn-batch.test.shunder real stock Bash 3.2.57, so this class of regression is caught on the actual target shell instead of only the Linux runners' modern bash.Test plan
bash -n bin/fm-brief.shandbash -n bin/fm-spawn.shunder/bin/bash3.2.57 (this machine's stock bash) and under a modern bashtests/fm-brief.test.sh(11/11) andtests/fm-spawn-batch.test.sh(3/3) pass under both bash versions$(cat <<EOF ... apostrophe ... EOF)fails to parse under 3.2 with both quoted and unquoted heredoc delimiters) and confirmed the post-fix script still parses even with an apostrophe re-injected into the DOD text--herdr-lab, secondmate) between the pre-fix and post-fix script under bash 3.2.57 - byte-identical after normalizing incidental scratch-path differencesbin/fm-lint.sh(pinned ShellCheck 0.11.0) - cleanmacos-stock-bashCI job steps locally in a sanitized stock-Bash environment - all passNo-mistakes gate note: review/document/lint all completed cleanly through the local no-mistakes gate. The test step's single lump finding covered 4 pre-existing failures in
tests/fm-backlog-handoff.test.sh,tests/fm-pi-watch-extension.test.sh,tests/fm-secondmate-lifecycle-e2e.test.sh, andtests/fm-turnend-guard.test.sh- none touch the files changed in this PR. Two were resolved by upgrading this sandbox's stale globaltasks-axi(0.1.2 -> 0.2.3, matching what CI installs fresh); the remaining two are a Node v23.7.0ExperimentalWarningruntime artifact in this sandbox, unrelated to firstmate code, so that gate step was skipped with documented reasoning rather than editing test files. The gate's automatedpushstep then failed with a GitHub permissions error (the local git identity lacks write access tokunchenguid/firstmate), so this PR was opened manually via a fork per captain direction instead of through the gate's own push/PR steps.