bash treats an empty array as if it were an unset variable, which seems very illogical as empty is quite distinct from unset:
$ myarray=() $ [[ -v myarray ]] && echo set || echo unset unset $ set | grep ^myarray= # yet, it's set: myarray=() $ set -u $ for i in "${x[@]}"; do :; done bash: x[@]: unbound variable Note also that the "unbound variable" error is inconsistent with the behaviour of "$@"; I would have thought that, logically, "$@" and "${x[@]}" should behave the same way, since arrays are implemented as a logical extension of the positional parameters concept. zsh and ksh93 can distinguish between empty and unset arrays. Thanks, - Martijn