|
From: | Edouard Thiel |
Subject: | Re: Error in bash documentation for builtin declare |
Date: | Fri, 6 Nov 2020 17:53:54 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
Le 06/11/2020 à 17:01, Greg Wooledge a écrit :
This is more clear, and in fact, ok for me (if subscripted means associative?);On Fri, Nov 06, 2020 at 02:07:36PM +0100, Edouard Thiel wrote: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+) (tested for bash version : 4.3.48(1)-release (x86_64-pc-linux-gnu))The relevant section in the 5.0 man page under PARAMETERS says: Array variables cannot be given the nameref attribute. However, nameref variables can reference array variables and subscripted array variables. What, exactly, did you test?
the link above is not up to date. By the way, I have seen that the nameref works more or less for functions: $ foo() { echo "hello" ;} $ declare -n bar=foo but the reference has to be dereferenced when calling: $ ${!bar} hello is it still the case in bash 5? Cheers, Edouard -- Professeur Edouard THIEL http://j.mp/ethiel Département Informatique et Interactions http://j.mp/dept-ii UFR Sciences, Aix-Marseille Université http://j.mp/fs-amu Laboratoire d'Informatique et Systèmes http://j.mp/lis-amu
[Prev in Thread] | Current Thread | [Next in Thread] |