Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #11376

Re: quoted compound array assignment deprecated

From isabella parakiss <izaberina@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: quoted compound array assignment deprecated
Date 2015-08-18 19:52 +0200
Message-ID <mailman.8555.1439920324.904.bug-bash@gnu.org> (permalink)
References <CAAZkfoJJdVc5A9WMmBcUqUMjN=2VBq6rtuoDYVO5iMQDoLjS9Q@mail.gmail.com> <55D34682.9000704@case.edu>

Show all headers | View raw


On 8/18/15, Chet Ramey <chet.ramey@case.edu> 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.
>
> 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/
>

Sorry for being both pedantic and late for that discussion but what's the
point of this warning?  From my understanding, the code is still valid, so
it doesn't stop a possible attacker and it only annoys regular users.

Using eval requires an extra level of escaping on everything else, I'd
rather use declare 2>/dev/null to suppress the warning than eval...

Idea: display the warnings in -n mode, like ksh.
This way bash wouldn't produce unexpected results on existing scripts, it
wouldn't even require a new compatibility level and shopt.
What do you think about it?


---
xoxo iza

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: quoted compound array assignment deprecated isabella parakiss <izaberina@gmail.com> - 2015-08-18 19:52 +0200

csiph-web