On 1/2/26 6:17 PM, Greg Wooledge wrote:
On Fri, Jan 02, 2026 at 17:24:46 -0500, Chet Ramey wrote:
On 12/31/25 6:58 PM, Koichi Murase wrote:
My request is essentially to defer the
identification of keys and values in non-subscripted forms after shell
expansions (while keeping the identification between subscripted vs
non-subscripted forms of lexical words to be performed before shell
expansions).

OK, you want a new feature. Since this is not compatible with previous
behavior, and since bash has never behaved this way, how should this new
feature be exposed?

Should there be a shell option that changes the expansion behavior?
Some new assignment syntax? Something else?

We're talking about this, right?

     assoc=( "${kv[@]}" )

No. We started there, but the current proposal is to extend the k-v
assignment syntax to perform word expansion, including word splitting,
on the word between the parens, before identifying the keys and values,
then perform no additional expansions.

This makes

k='key with spaces'
v='value with spaces'

declare -A assoc
assoc=( $k $v )

result in

assoc=( [key]=with [spaces]=value [with]=spaces )

instead of the current

assoc=(["key with spaces"]="value with spaces" )


Therefore, my preference would be to declare the current behavior a
bug and replace it with a new behavior, without offering any backward
compatibility option.

People have spent considerable time informing me that doing that is ...
bad. Any change in behavior like this, they say, should be gated by a
new shell option, or require new syntax. I'm really not interested in
repeating this debate.

What that new behavior should be is still a little murky to me, however.

You might want to read Koichi's proposal.

https://lists.gnu.org/archive/html/bug-bash/2025-12/msg00125.html

It goes further than I'd like, in that his proposal supports subscripted
array element assignment mixed with kvpair assignment. It doesn't propose
to change how subcripted assignments work, or how to determine whether or
not the compound assignment is subscripted or k-v pairwise assignment.


Maybe a new command like this would be the cleanest way forward.  A
bash equivalent might look something like:

     loadarray assoc "${kv[@]}"

Maybe add an option that'll clear any existing elements.

This sounds like a loadable builtin, if someone wants to take a run at it.

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

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to