On 11/6/20 8:07 AM, Edouard Thiel wrote:
> Hello,
> 
> there is an error in the bash documentation:
>     https://www.gnu.org/software/bash/manual/bash.html#Bash-Builtins
> 
> In the 'declare' builtin, option '-n',  last sentence:
>     "The nameref attribute cannot be applied to array variables"
> is actually wrong: it can be applied to indexed and associative arrays
> (since bash 4.3+)

Is this what you mean, or something else?

$ cat x3
echo $BASH_VERSION

declare -a foo=(a b c)
declare -n foo

declare -A bar=( [one]=1 [two]=2 )
declare -n bar

declare -an flip=(a b c)
declare -An flop=( [one]=1 [two]=2 )

declare -p foo bar flip flop
$ ../bash-5.0-patched/bash x3
5.0.18(9)-release
x3: line 4: declare: foo: reference variable cannot be an array
x3: line 7: declare: bar: reference variable cannot be an array
x3: line 9: declare: flip: reference variable cannot be an array
x3: line 10: declare: flop: reference variable cannot be an array
declare -a foo=([0]="a" [1]="b" [2]="c")
declare -A bar=([two]="2" [one]="1" )
declare -a flip=([0]="a" [1]="b" [2]="c")
declare -A flop=([two]="2" [one]="1" )


-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Reply via email to