bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Name collision with nameref and local variable


From: Chet Ramey
Subject: Re: Name collision with nameref and local variable
Date: Sun, 18 Oct 2020 14:34:54 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.12.1

On 10/16/20 11:23 AM, gringo@sun.STAT.CWRU.edu wrote:

> Bash Version: 5.0
> Patch Level: 18
> Release Status: release
> 
> Description:
> This worked just fine on Bash 4.2:
> 
> foo() {
>     local -a args=("${!1}")
>     echo "[IN] ${args[@]}"
> }
> 
> declare -a args=("$@")
> echo "Bash ${BASH_VERSION}"
> echo "[OUT] ${args[@]}"
> foo args[@]
> 
> eg.
> $ ./test.sh 1 2 3

Thanks for the report. There aren't any nameref variables there; this is
an order-of-evaluation problem resulting from the local array variable
declaration with the same name as the variable used in the word
expansion -- it doesn't depend on the indirect variable expansion. It was
fixed back in April, before bash-5.1-alpha was released.

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