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


Groups > gnu.bash.bug > #11396

Re: quoted compound array assignment deprecated

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 <chet.ramey@case.edu>
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 <mailman.8634.1439997144.904.bug-bash@gnu.org> (permalink)
References <CAAZkfoJJdVc5A9WMmBcUqUMjN=2VBq6rtuoDYVO5iMQDoLjS9Q@mail.gmail.com> <CAAZkfoJyOyo=2zE63OYaZua73E-HCTd4bCmMkJDNzhJ5hgVAgw@mail.gmail.com> <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 <izaberina@gmail.com>, chet.ramey@case.edu
To Dan Douglas <ormaaj@gmail.com>, 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 <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:11396

Show key headers only | View raw


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/

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


Thread

Re: quoted compound array assignment deprecated Chet Ramey <chet.ramey@case.edu> - 2015-08-19 10:07 -0400

csiph-web