>>> Chet Ramey <chet.ra...@case.edu> schrieb am 13.05.2019 um 21:44 in Nachricht <ead04541-953d-f1ba-f021-5c6938063...@case.edu>: > On 5/9/19 7:07 AM, Ulrich Windl wrote: >> Bash Version: 4.3 >> Patch Level: 48 >> Release Status: release >> >> Hi! >> >> Is this intended with "set -u": >> # set -u >> # declare -a INSTANCES >> # echo ${INSTANCES[*]} >> bash: INSTANCES[*]: unbound variable >> # INSTANCES=() >> # echo ${INSTANCES[*]} >> bash: INSTANCES[*]: unbound variable >> # echo ${INSTANCES[@]} >> bash: INSTANCES[@]: unbound variable > > This was changed late in the bash-4.4 development cycle (July, 2016). From > bash-4.4/CHANGES: > > a. Using ${a[@]} or ${a[*]} with an array without any assigned elements > when > the nounset option is enabled no longer throws an unbound variable > error.
Thanks for the info! Actually it seems "${#a[*]}" is also affected: v04:~> declare -a a v04:~> echo ${#a[@]} 0 v04:~> set -u v04:~> echo ${#a[@]} bash: a: unbound variable v04:~> a=() v04:~> echo ${#a[@]} 0 v04:~> echo $BASH_VERSION 4.3.48(1)-release Regards, Ulrich