bug-bash
[Top][All Lists]
Advanced

[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 14:16:36 -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 12:21 PM, Edouard Thiel wrote:

>>> 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?
>> Sure, it seems harmless to allow it.
> I mean, I was surprised I couldn't simply run
> $ bar

What would be reasonable to expect that to do? There's no word expansion,
so no opportunity to perform any kind of nameref expansion.

You can either use namerefs as you did above, or have no nameref attribute
and use ${bar}.

Chet

-- 
``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/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]