bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Consolidate recommended options?


From: Chet Ramey
Subject: Re: Consolidate recommended options?
Date: Tue, 31 Dec 2024 12:15:27 -0500
User-agent: Mozilla Thunderbird

On 12/29/24 4:34 PM, Lawrence Velázquez wrote:

I'm aware of the pitfalls described therein, and more.  I don't
think anyone thinks multiple evaluation in indexes is good per se,
but many find the side effects of the attempted cures worse than
the disease (e.g., https://mywiki.wooledge.org/BashPitfalls#pf62).

In its zeal to demonstrate how bad bash is, that little code snippet
ignores the obvious solution:

declare -A hash
key=\'\]
hash[$key]=17
(( hash[key]++ ))
declare -p hash

Since arithmetic evaluation performs its own expansion of identifiers.
assoc_expand_once also works. But that wasn't really the point, was it?

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]