I think all of the stuff here is fixed in the latest devel snapshot, though
there is definitely weirdness if you run the assignments as a typeset
command.  I hadn't even tried the ref4 case, which gives the weirdest
results when used with typeset/declare:
https://groups.google.com/forum/#!topic/gnu.bash.bug/Z-lf3KEnZ34

bash -xc '
    typeset -n ref1=a1 ref2=a2 ref3=a3[0] ref4=a4[0]
    ref1=foo ref2[0]=foo ref3=foo ref4[0]=foo
    echo "${ref1} ${ref2[0]} ${ref3} ${ref4[0]}"
    typeset -p {ref,a}{1,2,3,4}'
+ typeset -n ref1=a1 ref2=a2 'ref3=a3[0]' 'ref4=a4[0]'
+ ref1=foo
+ ref2[0]=foo
+ ref3=foo
+ ref4[0]=foo
bash: line 2: `a4[0]': not a valid identifier
+ echo 'foo foo foo '
foo foo foo
+ typeset -p ref1 ref2 ref3 ref4 a1 a2 a3 a4
declare -n ref1="a1"
declare -n ref2="a2"
declare -n ref3="a3[0]"
declare -n ref4="a4[0]"
declare -- a1="foo"
declare -a a2=([0]="foo")
declare -a a3=([0]="foo")
bash: line 4: typeset: a4: not found


bash -c 'typeset -n ref[0]=foo'
bash: line 0: typeset: ref[0]: reference variable cannot be an array

Reply via email to