fix(bin): keep --no-projects remote seeding working on stock macOS bash - #3541
fix(bin): keep --no-projects remote seeding working on stock macOS bash#3541zeeshaanahmad wants to merge 1 commit into
Conversation
fm-remote-home-seed.sh expanded "${PROJECT_NAMES[@]}" unguarded when
walking the project list. --no-projects leaves that array empty, and
bash 3.2 - macOS's stock shell, which `env bash` still resolves to on a
Mac - treats an empty array's [@] expansion as an unbound variable
under set -u, so the seed aborted before it ever reached remote
provisioning.
Use the guarded expansion the repo already uses elsewhere for this
case, so the loop is skipped rather than fatal.
Verified failing on unpatched upstream main (8988af2) on macOS with
stock bash 3.2: `bin/fm-remote-home-seed.sh ... --no-projects` fails
with "PROJECT_NAMES[@]: unbound variable" at the loop this patches;
tests/fm-remote-secondmate-trace-context.test.sh and
tests/fm-remote-secondmate-lifecycle-e2e.test.sh, both of which drive
the --no-projects path, fail the same way unpatched and pass with this
fix.
Confidence Score: 5/5The PR appears safe to merge, with no actionable regressions identified. The guarded expansion skips the project loop for an empty array on Bash 3.2 while retaining quoted, element-preserving expansion when projects are present. Reviews (1): Last reviewed commit: "fix(bin): keep --no-projects remote seed..." | Re-trigger Greptile |
|
Speaking as Kun's firstmate: HEAD Attestation: MISSING — no head-bound no-mistakes attestation. NM 33659002660 FAILURE ("PR was not raised through no-mistakes"). CI 33659002709 approved this pass and queued. Contract-class: restore — script usage already documents VISION (per rule, evidence = usage header + one-line loop fix):
This is waiting on you (the author), not a captain decision. Please workflow-approvals this pass: 33659002709, 33659002660 |
|
The no-mistakes pipeline has now been run against this branch, and its The pipeline was run against the fork remote with the |
Intent
Fix bin/fm-remote-home-seed.sh so --no-projects works on stock macOS bash 3.2. The project loop expands "${PROJECT_NAMES[@]}" unguarded; --no-projects leaves that array empty, and bash 3.2 treats an empty array's [@] expansion as an unbound variable under set -u, so the seed aborts with 'PROJECT_NAMES[@]: unbound variable' and the remote secondmate spawn fails. Guard the expansion so an empty project list is a valid no-op on bash 3.2 as well as on newer bash. The branch is based on upstream main and is contributed from a fork; the validation pipeline was run against the fork remote with the CI step skipped, because this repository's CI runs on the upstream pull request rather than on the fork.
What Changed
bin/fm-remote-home-seed.sh, guard the"${PROJECT_NAMES[@]}"expansion in the project loop with the${PROJECT_NAMES[@]+"${PROJECT_NAMES[@]}"}idiom so an emptyPROJECT_NAMESarray (produced when--no-projectsis passed) is a valid no-op instead of triggering an unbound-variable error.env bashresolves to on a Mac) treats"${ARR[@]}"on an empty array as unbound underset -u, unlike newer bash versions.Risk Assessment
✅ Low: Single-file, 5-line change applying the standard bash 3.2-safe empty-array guard exactly where the described unbound-variable failure occurs; verified against real bash 3.2 that the fix resolves the failure, preserves element quoting, and that the one other unguarded PROJECT_NAMES[@] use is unreachable when the array is empty.
Testing
Reproduced the exact reported bash 3.2 failure in isolation (unguarded
"${PROJECT_NAMES[@]}"on an empty array aborts with 'unbound variable' under set -u; the fixed guarded expansion${PROJECT_NAMES[@]+"${PROJECT_NAMES[@]}"}completes cleanly), then confirmed the fix end-to-end by running the existing tests/fm-remote-secondmate-trace-context.test.sh under this machine's actual stock bash 3.2.57 (bothbashand/bin/bashresolve to it here), which invokes fm-remote-home-seed.sh with --no-projects twice and drives the full remote secondmate spawn afterward — all assertions passed. An initial run appeared to hang/time out at the 3-minute mark, but this was CPU contention from a concurrent shellcheck lint phase in the same outer pipeline (confirmed viaps), not a fix regression; a clean re-run after that contention cleared finished in ~2:39 with all tests passing. No source or test changes were needed; worktree is clean with no transient artifacts left behind.Evidence: Isolated bash 3.2 before/after reproduction
Evidence: tests/fm-remote-secondmate-trace-context.test.sh full run under bash 3.2.57
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
⏭️ **Rebase** - skipped
Step was skipped.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
Isolated bash 3.2.57 repro: pre-fixfor project in "${PROJECT_NAMES[@]}"on an empty array underset -eufails withPROJECT_NAMES[@]: unbound variable; post-fixfor project in ${PROJECT_NAMES[@]+"${PROJECT_NAMES[@]}"}completes as a no-op (exit 0)/bin/bash tests/fm-remote-secondmate-trace-context.test.sh(this environment's defaultbashand/bin/bashare both stock macOS bash 3.2.57) — exercisesbin/fm-remote-home-seed.sh ... --no-projectstwice end-to-end (real script,set -eu) followed by realfm-spawn.sh --secondmateremote spawns; all 6 assertions passed,ALL TESTS PASSED, exit 0✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.