Re: New word splitting semantics for kvpair compound assignment
Zachary Santer <[email protected]>
| Newsgroups | gmane.comp.shells.bash.bugs |
|---|---|
| Message-ID | <CABkLJUJqGxRtzfKro0BUtOG8jW0-txtC7XhviEShSrYgoeH73w@mail.gmail.com> |
On Mon, Aug 17, 2026 at 10:35 AM Chet Ramey <[email protected]> wrote: > > Please test it out and let me know what you think, and what should change. Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: cygwin Compiler: gcc Compilation CFLAGS: -g -O2 uname output: MSYS_NT-10.0-26200 ZackFramework16 3.6.10-8fbd9808.x86_64 2026-08-13 11:15 UTC x86_64 Msys Machine Type: x86_64-pc-cygwin Bash Version: 5.3 Patch Level: 0 Release Status: maint git commit 2f7eb80c77 This has no effect on key-value pair compound assignment as part of a declaration command. $ declare -p BASH_VERSION declare -- BASH_VERSION="5.3.0(1)-maint" $ declare -a kv=( zero 0 one 1 two 2 three 3 four 4 ) $ declare -A assoc $ assoc=( "${kv[@]}" ) $ declare -p assoc declare -A assoc=([four]="4" [two]="2" [three]="3" [one]="1" [zero]="0" ) $ declare -A assoc_copy1=( "${assoc[@]@k}" ) $ declare -p assoc_copy1 declare -A assoc_copy1=(["four 4 two 2 three 3 one 1 zero 0"]="" ) $ assoc_func () { > local -A assoc_copy2=( "${assoc[@]@k}" ) > declare -p assoc_copy2 > } $ assoc_func declare -A assoc_copy2=(["four 4 two 2 three 3 one 1 zero 0"]="" ) $ readonly -A assoc_copy3=( "${assoc[@]@k}" ) $ declare -p assoc_copy3 declare -Ar assoc_copy3=(["four 4 two 2 three 3 one 1 zero 0"]="" ) $ export -A assoc_copy4=( "${assoc[@]@k}" ) $ declare -p assoc_copy4 declare -Ax assoc_copy4=(["four 4 two 2 three 3 one 1 zero 0"]="" ) I know that bash by default can't actually export indexed or associative arrays into the environment, but was that last bit just undocumented behavior, or was that not supposed to happen at all? $ export -a kv_copy1=( "${kv[@]}" ) $ declare -p kv_copy1 declare -ax kv_copy1=([0]="zero" [1]="0" [2]="one" [3]="1" [4]="two" [5]="2" [6]="three" [7]="3" [8]="four" [9]="4") :/ I have a hard time believing that anyone would take advantage of the prior key-value pair compound assignment behavior. I don't see a point to the new kvpair_split shopt option. The description of the readonly command in the devel branch doc/bash.1 includes a little typo: > This sets the value of the variable ~~is~~ to value while modifying the readonly attribute. Zack