You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bash 3.2 on macOS treats empty arrays under set -u as unbound when expanded as "${array[@]}".
This bit KnickKnackLabs/winnie#36 on hosted macOS CI. iso:get had:
set -euo pipefail
arch_args=()
[[ -n"$ARCH_FLAG" ]] && arch_args=(--arch "$ARCH_FLAG")
mise -C "$TASK_ROOT" run -q "catalog:$DISTRO" -- --json "${arch_args[@]}"
When ARCH_FLAG was empty, hosted macOS failed with:
.mise/tasks/iso/get: line 37: arch_args[@]: unbound variable
Linux/modern Bash and local runs did not catch it. The fix was the Bash-3-safe expansion:
mise -C "$TASK_ROOT" run -q "catalog:$DISTRO" -- --json ${arch_args[@]+"${arch_args[@]}"}
Desired lint
Add a lint rule that flags "${name[@]}" array expansions in Bash files that enable nounset (set -u, set -eu, set -euo pipefail, etc.) unless the expansion already uses the safe alternate-value form.
Problem
Bash 3.2 on macOS treats empty arrays under
set -uas unbound when expanded as"${array[@]}".This bit
KnickKnackLabs/winnie#36on hosted macOS CI.iso:gethad:When
ARCH_FLAGwas empty, hosted macOS failed with:Linux/modern Bash and local runs did not catch it. The fix was the Bash-3-safe expansion:
Desired lint
Add a lint rule that flags
"${name[@]}"array expansions in Bash files that enable nounset (set -u,set -eu,set -euo pipefail, etc.) unless the expansion already uses the safe alternate-value form.Flag:
Suggest:
Scope notes
$@forwarding under nounset).ShellCheckdid not catch the Winnie case.Provenance
Found while adding Fedora support + template-shaped CI to
KnickKnackLabs/winnie#36. Hosted macOS failed after Ubuntu and local validation passed.