bug-bash
[Top][All Lists]
Advanced

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

Re: No expansions performed while declaring an associative array using a


From: Chet Ramey
Subject: Re: No expansions performed while declaring an associative array using a list of keys and values
Date: Wed, 16 Dec 2020 11:09:32 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.5.1

On 12/16/20 10:58 AM, Glenn Jackman wrote:
On 2020-12-15 16:58, Chet Ramey wrote:
On 12/15/20 11:23 AM, Glenn Jackman wrote:
I would think that these pairs of invocations would correspond:

      declare -A v1=$( $foo 3 )
      declare -A v1=$( [1]=2 [3]="")

      declare -A v1=$( "$foo" 3 )
      declare -A v1=$( ['1 2']=3 )

Do word splitting and quote removal not occur within the parentheses of an
_associative_ array definition?

Associative array keys do not undergo word splitting on assignment, whether
they are used in a subscript or the alternate key-value synatx. This has
been the case since their introduction in bash-4.0.

Ah, that's the bit I was missing. Thank you for taking the time to
clarify. I don't see that documented in the manual though. Where did I
miss it?

It's not stated explicitly; it simply does not make sense to do it any other way.

--
``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/



reply via email to

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