help-bash
[Top][All Lists]
Advanced

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

Re: Bash-5.2 Release available


From: Corey Hickey
Subject: Re: Bash-5.2 Release available
Date: Mon, 31 Oct 2022 15:17:36 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1

On 2022-10-31 15:15, Greg Wooledge wrote:
On Mon, Oct 31, 2022 at 03:00:42PM -0700, Corey Hickey wrote:
Greg, why do you say this part?

https://mywiki.wooledge.org/BashPitfalls#pf62

    As of bash 5.2, the only safe, working way to modify an element of an
    associative array in a calculation is to make a temporary copy of the
    value in a regular (string) variable.

I can see that pre/post 5.2 compatibility would be problematic
without a temporary variable--earlier versions of bash require escaping
the dollar sign and 5.2 does not give that any special meaning.

Other than forward/backward compatibility, is there some other problem
with the 5.2 behavior that I am missing? From what I've seen so far, 5.2
(with Chet's patch) has the least surprising behavior to me (given that
I consider recursive expansion of array keys to be surprising).

I might not have written it as clearly as possible.  Using a temporary
variable to retrieve the associative array element outside of the math
context is the only way that'll work across bash versions without
triggering code injection *or* a key lookup failure.

Ok, thanks. That's definitely consistent with what I'm seeing.

-Corey



reply via email to

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