Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #11392
| From | Mike Frysinger <vapier@gentoo.org> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: quoted compound array assignment deprecated |
| Date | 2015-08-18 23:41 -0400 |
| Message-ID | <mailman.8608.1439955696.904.bug-bash@gnu.org> (permalink) |
| References | <CAAZkfoJJdVc5A9WMmBcUqUMjN=2VBq6rtuoDYVO5iMQDoLjS9Q@mail.gmail.com> <55D34682.9000704@case.edu> |
[Multipart message — attachments visible in raw view] - view raw
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
Back to gnu.bash.bug | Previous | Next | Find similar
Re: quoted compound array assignment deprecated Mike Frysinger <vapier@gentoo.org> - 2015-08-18 23:41 -0400
csiph-web