[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Error in bash documentation for builtin declare
From: |
Chet Ramey |
Subject: |
Re: Error in bash documentation for builtin declare |
Date: |
Fri, 6 Nov 2020 11:43:39 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 |
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 chet@case.edu http://tiswww.cwru.edu/~chet/
Re: Error in bash documentation for builtin declare,
Chet Ramey <=