Guard optional-array loops for macOS bash 3.2 #1

Merged
stephen merged 1 commit from fix-bash32-empty-arrays into main 2026-06-02 03:15:13 +00:00
Owner

A downstream macOS release build failed in this action with:

scripts/setup.sh: line 43: _components[@]: unbound variable

setup.sh runs under set -euo pipefail. With no components / targets inputs, _components and _targets are empty arrays, and on macOS bash 3.2 "${arr[@]}" on an empty array under set -u aborts with "unbound variable". The Linux CI runner's newer bash tolerates the unguarded form, which is why test.yml stayed green while macOS consumers broke.

Fix: expand the optional-array loops through the ${arr[@]+"${arr[@]}"} guard, so the empty case expands to nothing. Verified by running the patched setup.sh end-to-end under /bin/bash 3.2 with empty inputs (exit 0, correct rustup assembly).

Also adds a static guard to tests/run.sh asserting both loops keep the [@]+ form, since a Linux-only runtime test can't reproduce the 3.2 behavior.

After merge this needs the v1 tag moved (and a v1.0.1) so consumers on @v1 pick it up.

A downstream macOS release build failed in this action with: ``` scripts/setup.sh: line 43: _components[@]: unbound variable ``` `setup.sh` runs under `set -euo pipefail`. With no `components` / `targets` inputs, `_components` and `_targets` are empty arrays, and on macOS **bash 3.2** `"${arr[@]}"` on an empty array under `set -u` aborts with "unbound variable". The Linux CI runner's newer bash tolerates the unguarded form, which is why `test.yml` stayed green while macOS consumers broke. Fix: expand the optional-array loops through the `${arr[@]+"${arr[@]}"}` guard, so the empty case expands to nothing. Verified by running the patched `setup.sh` end-to-end under `/bin/bash` 3.2 with empty inputs (exit 0, correct rustup assembly). Also adds a static guard to `tests/run.sh` asserting both loops keep the `[@]+` form, since a Linux-only runtime test can't reproduce the 3.2 behavior. After merge this needs the `v1` tag moved (and a `v1.0.1`) so consumers on `@v1` pick it up.
Guard optional-array loops for macOS bash 3.2
All checks were successful
test / unit (pull_request) Successful in 4s
test / e2e (pull_request) Successful in 27s
fe46ff84d4
`scripts/setup.sh` runs under `set -euo pipefail`. When no components or
targets are passed, `_components` / `_targets` are empty arrays, and on
macOS bash 3.2 `"${arr[@]}"` on an empty array under `set -u` aborts with
"unbound variable". The Linux CI runner's newer bash tolerates it, so the
break only showed up on a macOS runner (a downstream release build).

Use the `${arr[@]+"${arr[@]}"}` guard so the no-input path expands to
nothing instead of erroring. Adds a static check to the unit suite that
both loops keep the guard (a runtime case can't catch this on the Linux
runner's bash).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
rasterstate/setup-rust-action!1
No description provided.