fix(bootstrap): EXTRA_ARGS expansion produced phantom empty positional arg#3
Merged
Merged
Conversation
…l arg
bootstrap.sh ended with:
ansible-playbook ... "${EXTRA_ARGS[@]:-}"
When EXTRA_ARGS=() (the no-`--` invocation, which is the documented
baseline path), `${arr[@]:-}` expands to a SINGLE empty-string
positional argument, not zero arguments. ansible-playbook receives
"" as a trailing positional, doesn't recognize it, and bails with
the unhelpful error 'unrecognized arguments:' (with empty space
after the colon -- the empty string is the bad arg).
The `:-` default form treats arrays the same as scalars: returns
the default string when null/empty. For arrays we want zero
positional args, not the default. The canonical safe form for
bash-3.2+ under `set -u` is:
${arr[@]+"${arr[@]}"}
which expands to nothing if the array is unset OR empty, and to
the array contents otherwise. Safe under `set -u` because
EXTRA_ARGS=() is always declared at the top of the script.
Verified with a mock ansible-playbook that prints argc + each
arg:
==== old broken behavior ====
argc=7
arg[6]=[--diff]
arg[7]=[] <-- phantom empty positional arg
==== fixed: empty EXTRA_ARGS ====
argc=6
arg[6]=[--diff] <-- no trailing arg
==== fixed: non-empty EXTRA_ARGS=(--check -vv) ====
argc=8
arg[6]=[--diff]
arg[7]=[--check]
arg[8]=[-vv]
Fixes #2.
This was referenced May 23, 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.
What
Change the EXTRA_ARGS expansion in
bootstrap.shfrom"${EXTRA_ARGS[@]:-}"to${EXTRA_ARGS[@]+"${EXTRA_ARGS[@]}"}.Why
Fixes #2.
Surfaced bootstrapping a fresh Mac Studio on 2026-05-23. The
./bootstrap.shbaseline invocation (no--passthrough args) failedwith
ansible-playbook: error: unrecognized arguments:because the:-default form was passing a single empty-string positional toansible-playbook instead of zero args.
How
The
${arr[@]+"${arr[@]}"}pattern is bash-3.2+ canonical for'expand to nothing when array is empty, expand to contents
otherwise.' Safe under
set -ubecause EXTRA_ARGS is alwaysdeclared as
()at the top of the script.Behavior verified against a mock binary that echoes argc + each arg:
[](empty positional) -- bug--check -vv[--check] [-vv]Verification
Mock-bash tested locally. Real end-to-end via
./bootstrap.shon afresh Mac Studio happens immediately after merge.
Checklist
this repo yet)