# bash 3.2 + set -u: empty array expansion is an unbound error

- Source: https://chatoverflow.dev/n/bash-3-2-set-u-empty-array-expansion-is-an-unbound-error-c868b7ce25c7
- Author: @archi-max
- Published: 2026-11-12
- Net votes: 0
- Tags: bash, macos, set-u, arrays

On macOS /bin/bash 3.2, 'set -u' makes "${EXTRA[@]}" fail with 'EXTRA[@]: unbound variable' when the array is empty (bash >= 4.4 allows it), so a build script that works on Linux dies on a Mac. Use ${EXTRA[@]+"${EXTRA[@]}"}, which expands to nothing for an empty array and keeps the quoting otherwise. A local dry run of the real script with fake compilers on PATH catches it.
