On 2/19/20 6:18 PM, Arfrever Frehtes Taifersar Arahesis wrote: > While described problems exist, there were typos in original reproduction > steps. > > Corrected output also reveals another bug: > ${!variable[@]@A} for (indexed or associative) arrays does not include > indexes. Your examples are all (still) broken. Do not try to reproduce bugs using:
VAR1=(aaa) Instead, use: VAR1=(aaa bbb) Reformulate all test cases where you expect the bbb to be printed, but it isn't. $ VAR1=(aaa bbb) $ ref=VAR1 $ echo "${!ref[@]}" 0 $ echo "${!ref[@]@A}" declare -a VAR2='aaa' $ ref2=VAR1[@] $ args() { printf '<%s> ' "$@"; printf \\n; } $ args "${!ref2}" <aaa> <bbbb> $ args "${!ref2@A}" <> You cannot use ${!ref[@]}, you need the array subscript as part of the set value of "ref" and then indirectly refer to ref. $ declare -A VAR2=([foo]=bar [baz]="how interesting") $ args "${!VAR2[@]}" <foo> <baz> From man bash: ``` ${!name[@]} ${!name[*]} List of array keys. If name is an array variable, expands to the list of array indices (keys) assigned in name. If name is not an array, expands to 0 if name is set and null otherwise. When @ is used and the expansion appears within double quotes, each key expands to a separate word. ``` And, as predicted, if instead of using ${!ref[@]} you use ${!varname[@]}, you get meaningful information. If you try to look at the array keys of "ref" itself, all it prints is the number 0, because: ref=VAR1 and since it is set and non-null... -- Eli Schwartz Arch Linux Bug Wrangler and Trusted User
signature.asc
Description: OpenPGP digital signature