Guard optional-array loops for macOS bash 3.2 #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix-bash32-empty-arrays"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A downstream macOS release build failed in this action with:
setup.shruns underset -euo pipefail. With nocomponents/targetsinputs,_componentsand_targetsare empty arrays, and on macOS bash 3.2"${arr[@]}"on an empty array underset -uaborts with "unbound variable". The Linux CI runner's newer bash tolerates the unguarded form, which is whytest.ymlstayed 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 patchedsetup.shend-to-end under/bin/bash3.2 with empty inputs (exit 0, correct rustup assembly).Also adds a static guard to
tests/run.shasserting both loops keep the[@]+form, since a Linux-only runtime test can't reproduce the 3.2 behavior.After merge this needs the
v1tag moved (and av1.0.1) so consumers on@v1pick it up.`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).