Path: csiph.com!au2pb.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!news.ripco.com!news.glorb.com!usenet.stanford.edu!not-for-mail From: Chet Ramey Newsgroups: gnu.bash.bug Subject: Re: quoted compound array assignment deprecated Date: Wed, 19 Aug 2015 10:07:46 -0400 Lines: 40 Approved: bug-bash@gnu.org Message-ID: References: <55D38D5C.2050605@case.edu> <1645236.4mLlXIIrB0@smorgbox> Reply-To: chet.ramey@case.edu NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: usenet.stanford.edu 1439997145 26836 208.118.235.17 (19 Aug 2015 15:12:25 GMT) X-Complaints-To: action@cs.stanford.edu Cc: isabella parakiss , chet.ramey@case.edu To: Dan Douglas , bug-bash@gnu.org Envelope-to: bug-bash@gnu.org X-Enigmail-Draft-Status: N1110 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 In-Reply-To: <1645236.4mLlXIIrB0@smorgbox> X-Junkmail-Status: score=10/50, host=mpv5.cwru.edu X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 129.22.105.36 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:11396 On 8/18/15 5:05 PM, Dan Douglas wrote: > Sorry I meant to reply to that thread but ran out of time. I think Stephane's > eventual proposal was pretty close to what I had in mind but expressed badly. > I'm not sure why it was eventually decided to deprecate the current system > entirely but I'm not opposed to the idea - especially if it provides no > functionality for which there aren't easy workarounds. Deprecated doesn't mean removed. In this case, the meaning is closer to discouraged or deemphasized. Bash understands `declare' as a Posix declaration utility, and does its best to treat arguments to declare and other declaration utilities identically to standalone assignment statements. The place where that breaks down is if a compound array assignment is treated as such by declare when it would have been treated as a scalar assignment had it appeared standalone. That's why the warning. It's not an error. > The only thing I'm actively abusing this for at the moment in scripts I > actually use is as a way of encoding 2D arrays. It's very much a read-only > datastructure too. > > ~ $ ( key1=foo key2=bar; declare -A a=([foo]='([bar]=baz)') "b=${a[$key1]}" > typeset -p a b; echo "${b[$key2]}" ) > declare -A a='([foo]="([bar]=baz)" )' > declare -A b='([bar]="baz" )' > baz > > Any change will likely break this property but I think wrapping it in eval > gives the same result. This will continue to work, but with a warning about a potentially dangerous construct. -- ``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/