Old behavior, bash 4.2.45:

$ bash -c 'set -u; echo ${#arr1[@]}'; \
bash -c 'set -u; declare var1; echo ${#var1}'; \
bash -c 'set -u; declare -a arr2; echo ${#arr2[@]}'
bash: arr1: unbound variable
bash: var1: unbound variable
0

New behavior, bash 4.3:

$ bash -c 'set -u; echo ${#arr1[@]}'; \
bash -c 'set -u; declare var1; echo ${#var1}'; \
bash -c 'set -u; declare -a arr2; echo ${#arr2[@]}'
bash: arr1: unbound variable
bash: var1: unbound variable
bash: arr2: unbound variable

I suppose that this change in behavior makes array variables more
consistent with normal variables, but I couldn't find anything in
CHANGES which obviously relates to this, so I'm not sure if this is a
bug or not.

Was I always mistaken in figuring that declaring an array also
initialized it?

-- 
Richard Tollerton <rich.toller...@ni.com>

Reply via email to