This multiple-vars-at-same-scope thing happens also happens in the case
that the nameref points to a variable at a higher scope of the same name as
the nameref. I suspect this is related to the nameref resolution issue here
http://lists.gnu.org/archive/html/bug-bash/2016-05/msg00115.html

Given a function:

f() { local -n a=$1; a=X; }

The following works as expected:

$ a=(0); f 'a'
$ while [[ -v a ]]; do declare -p a; unset a; donedeclare -a a=([0]="X")

But the following does something strange:

$ a=(0); f 'a[0]'
$ while [[ -v a ]]; do declare -p a; unset a; donedeclare -a
a=([0]="X")declare -a a=([0]="0")

​

Reply via email to