On Tue, Mar 19, 2024 at 11:18 PM Zachary Santer <zsan...@gmail.com> wrote: > > Repeat-By: > > $ declare -A assoc_1=( [key 0]='value 0' [key 1]='value 1' [key > 2]='value 2' [key 3]='value 3' ) > $ unset assoc_2 > $ declare -A assoc_2 > $ printf '|%s|\n' "${assoc_1[*]@k}" > |key 2 value 2 key 3 value 3 key 0 value 0 key 1 value 1| > # All one word. Makes sense. > $ assoc_2=( "${assoc_1[*]@k}" ) > $ declare -p assoc_2 > declare -A assoc_2=(["key 2 value 2 key 3 value 3 key 0 value 0 key 1 > value 1"]="" ) > # Still makes sense. > $ printf '|%s|\n' "${assoc_1[@]@k}" > |key 2| > |value 2| > |key 3| > |value 3| > |key 0| > |value 0| > |key 1| > |value 1| > # Got expanded to separate words, like it's supposed to. > $ assoc_2=( "${assoc_1[@]@k}" ) > $ declare -p assoc_2 > declare -A assoc_2=(["key 2 value 2 key 3 value 3 key 0 value 0 key 1 > value 1"]="" ) > # Here, it did not.
This is specific to the compound assignment syntax for an associative array, even. $ unset array_1 $ declare -a array_1 $ array_1=( "${assoc_1[*]@k}" ) $ declare -p array_1 declare -a array_1=([0]="key 2 value 2 key 3 value 3 key 0 value 0 key 1 value 1") $ array_1=( "${assoc_1[@]@k}" ) $ declare -p array_1 declare -a array_1=([0]="key 2" [1]="value 2" [2]="key 3" [3]="value 3" [4]="key 0" [5]="value 0" [6]="key 1" [7]="value 1")