Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!usenet.stanford.edu!not-for-mail From: isabella parakiss Newsgroups: gnu.bash.bug Subject: Re: quoted compound array assignment deprecated Date: Tue, 18 Aug 2015 19:52:00 +0200 Lines: 47 Approved: bug-bash@gnu.org Message-ID: References: <55D34682.9000704@case.edu> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: usenet.stanford.edu 1439920324 19637 208.118.235.17 (18 Aug 2015 17:52:04 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash To: chet.ramey@case.edu Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=POrDxSBtPcBOjRR7ipW7F42exsIkoHD1z2rWyb7o1n8=; b=pmd395MLtBsjLnwTknFqge8yDEgM6KXov23G4XtMxMOX7RY2Hhy69U3y0h98U489VE D3VbDB99x5pwlfrH+a+d83Rh4KDmywlPAmDxHHb5uCCSfUl7A0ZXaLMGlgGJwoF3VwDO Ozk/muuzaOweIRpvgDLhApcHDKuVa45ij31IjrOgHy2YIDiYb0x+HD2SntKYnfwNOWci kcbXws7KEo9X8HUiw201zfYYo9y2AQbfXr5T5QX8/RN1L7p5MjK3vZimjkHRN5V9xFNh UEha92C6LUFagH69DmWi/wCV5vugepmrSWBiqIb1sokwR99dr8B4DiB/KjTmHex9XRfl wZfw== X-Received: by 10.50.102.100 with SMTP id fn4mr2672970igb.55.1439920320231; Tue, 18 Aug 2015 10:52:00 -0700 (PDT) In-Reply-To: <55D34682.9000704@case.edu> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4001:c05::233 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:11376 On 8/18/15, 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. > > 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