help-bash
[Top][All Lists]
Advanced

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

Re: How do we get state of a flag in set -o ...


From: Chet Ramey
Subject: Re: How do we get state of a flag in set -o ...
Date: Wed, 12 Jul 2023 10:19:23 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

On 7/11/23 6:11 PM, Kerin Millar wrote:

It is even true of variable expansion.

$ declare -A map; str="two words"; map=( $str ); declare -p map
declare -A map=(["two words"]="" )

It seems like a bug to me. It's certainly counter-intuitive. For indexed 
arrays, word splitting occurs. I see no particular reason for associative 
arrays to be a special case.

You have it backwards. Word splitting doesn't happen on the rhs of an
assignment statement. It happens for indexed arrays in this particular
case because I did it for ksh compatibility (because the behavior of a list
of words in a compound assignment to an indexed array was well-defined), so
indexed arrays are the exception. Note that it doesn't take place for
assignment words in a compound array assignment, making it even more of a
special case.

Now that key-value pairs in compound assignments to associative arrays
are well-defined, it might make sense to extend the associative array
compound assignments to perform word splitting, but that's not backwards
compatible, and the whole idea of key-value assignments is to mimic
the semantics of ( [key]=value ... ).

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