Hi, Am 04.02.2016 um 00:43 schrieb Martijn Dekker:
> 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 Which version of bash are you using? > $ set | grep ^myarray= # yet, it's set: > myarray=() > $ set -u Doesn't -u force just the behavior you observe, what if using +u? -- Reuti > $ 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 >