bug-bash
[Top][All Lists]
Advanced

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

Re: quoted compound array assignment deprecated


From: Mike Frysinger
Subject: Re: quoted compound array assignment deprecated
Date: Tue, 18 Aug 2015 23:41:26 -0400

On 18 Aug 2015 10:51, Chet Ramey wrote:
> On 8/17/15 4:19 AM, isabella parakiss wrote:
> > Quoting is necessary in a few cases:
> > 
> > $ var=foo; declare -A "arr$var=([x]=y)"
> > bash: warning: arrfoo=([x]=y): quoted compound array assignment deprecated
> > $ var=foo; declare -A arr$var=([x]=y)
> > bash: syntax error near unexpected token `('
> > $ var=foo; declare -A "arr$var"=([x]=y)
> > bash: syntax error near unexpected token `('
> > 
> > I don't think this should be the default behaiour...
> 
> This is exactly the case for which the warning is intended.  If you want
> to construct variable names on the fly, use `eval' or don't mix
> declarations of constructed variable names with compound assignment.
> 
> You can read the extensive discussion starting at
> http://lists.gnu.org/archive/html/bug-bash/2014-12/msg00028.html.
> 
> http://lists.gnu.org/archive/html/bug-bash/2014-12/msg00115.html is the
> newest proposal.

just to double check, the warning from this code is expected ?

$ bash-4.3 -c 'declare -a foo=(a b c); export foo; declare -p foo'
declare -ax foo='([0]="a" [1]="b" [2]="c")'
$ bash-4.4 -c "declare -a foo='(a b c)'"
bash-4.4: warning: foo=(a b c): quoted compound array assignment deprecated

we see this in Gentoo because we save/restore build envs via bash.  so all
builds done w/bash-4.3 and older use the quoted syntax, so updating with
bash-4.4 in the system triggers these warnings.  we can adjust our tooling
to handle it, but would be nice if older bash didn't do it either.  maybe
send out a 4.3-p43 ? ;)
-mike

Attachment: signature.asc
Description: Digital signature


reply via email to

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