If -u is on and you declare a simple or associative array 'y' and set it empty, 
then ${y@a} will fail with 'unbound variable'.
I was able to repro this under 5.1.0(1)-release and 5.1.8. 5.0.17(1)-release 
does not seem to be affected.

The code to reproduce (output lines begin with #>):

echo $BASH_VERSION
#> 5.1.0(1)-release
set -u
declare -a y=()
echo ${y@a}
#> bash: y: unbound variable
declare -p y
#> declare -a y=()
echo ${y[@]}
#>
set +u
echo ${y@a}
#> a

As you can see, turning off -u makes ${y@a} work correctly. 
I wonder if this is a side-effect of the fix that you described in item (n) of 
the most recent change log:

n. Fixed a bug that caused ${foo@a} to treat foo as an unset variable if it was 
an array without a value for subscript 0/"0" but had other set elements

Thanks,
-Mark

Reply via email to