[Top][All Lists]

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

Re: ${assoc[key]+set} no longer works.

From: Chet Ramey
Subject: Re: ${assoc[key]+set} no longer works.
Date: Wed, 19 Mar 2014 22:32:42 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.3.0

On 3/19/14, 5:42 PM, Geir Hauge wrote:

>     > Description:
>     >     With an associative array, assoc, ${assoc[key]+set} expands to the
>     >     empty string if the associated value is the empty string.
>     Thanks for the report.  This was a consequence of a change made back in
>     2011 to expand the value portion of the assignment statement a slightly
>     different way.  I've attached a patch to fix it.
> Thanks. That patch also makes  [[ -v assoc[x] ]]  return 0. However,
> [[ -v assoc ]] returns 1 (which it also does before the patch). Sounds
> related to this bug.

That's not a bug.  Referencing any array without a subscript is equivalent
to referencing subscript 0.  In the case of an associative array, that's


``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

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