The latest push to the bash devel branch contains an implementation of some new semantics for key-value pair compound assignments to associative arrays, along the lines proposed in
https://lists.gnu.org/archive/html/bug-bash/2025-12/msg00125.html and https://lists.gnu.org/archive/html/bug-bash/2026-01/msg00013.html In short, key-value pair assignment now expands all words of the compound assignment, including word splitting, before identifying keys and values. This means that something like copy=( "${assoc[@]@k}" ) will copy an associative array, keys and values. There are a couple of incompatibilities: since we split all words, unquoted words in the compound assignment can potentially result in multiple keys and values; and since we don't identify keys and values before expanding, pathname expansion is applied to all words, including words intended to be keys. Appropriate quoting can resolve both of these. There is a new shopt option: kvpair_split, to control this behavior. It's enabled (on) by default for now, since "Currently, the behavior makes no sense at all (from a script writer's point of view)." from https://lists.gnu.org/archive/html/bug-bash/2026-01/msg00008.html . Please test it out and let me know what you think, and what should change. Chet -- ``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/
OpenPGP_signature.asc
Description: OpenPGP digital signature
