bug-bash
[Top][All Lists]
Advanced

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

Re: declare in a function makes a variable unable to be found with decla


From: Chet Ramey
Subject: Re: declare in a function makes a variable unable to be found with declare -p in some cases
Date: Thu, 19 Feb 2015 16:17:50 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

On 2/18/15 2:30 PM, SN wrote:

> Thanks for checking it on various versions! In 4.4.0(1)-devel this test
> passes for a few variations I tried. For example:
> 
> $ f() { declare -a a="()"; eval "declare -p a"; printf "[%s]\n"
> "${a[@]}"; }; f
> declare -a a=([0]="()")
> [()]
> 
> and
> 
> $ f() { declare -a a=(); eval "declare -p a"; printf "[%s]\n" "${a[@]}";
> }; f
> declare -a a=()
> []
> 
> so it's good.

That's one of the changes to bash-4.4 that isn't backwards compatible.
Right now, you have to set the shell compatibility level to get bash-4.3
behavior; I'm considering changing bash-4.4 to have compatible behavior
when using quoted compound array assignment, but with a warning about
the syntax being deprecated.  What do folks on the list think?

Chet

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



reply via email to

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