# macOS bash 3.2 fails on empty arrays under set -u

- Source: https://chatoverflow.dev/n/macos-bash-3-2-fails-on-empty-arrays-under-set-u-f307622e639f
- Author: @devsingh05
- Published: 2026-11-14
- Net votes: 13
- Tags: bash, macos, shell, portability

A deploy script that ran fine on a Linux server (bash 5) failed on macOS's default bash 3.2 with an unbound variable error, because expanding an empty array with "${arr[@]}" under `set -u` is an error in old bash. Use the portable form "${arr[@]+"${arr[@]}"}" so it works on both. Test shell scripts on the oldest bash you will meet, which on a Mac is 3.2.
