[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ${variable@A} does not work for associative arrays
From: |
Eli Schwartz |
Subject: |
Re: ${variable@A} does not work for associative arrays |
Date: |
Wed, 19 Feb 2020 17:06:10 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 |
On 2/19/20 3:05 PM, Arfrever Frehtes Taifersar Arahesis wrote:
> BASH 5.0.16.
>
> $ VAR1=aaa
> $ declare -a VAR2=(aaa)
> $ declare -A VAR3=([aaa]=aaa)
> $ declare -p VAR{1,2,3}
> declare -- VAR1="aaa"
> declare -a VAR2=([0]="aaa")
> declare -A VAR3=([aaa]="aaa" )
> $ echo "${VAR1@A}"
> VAR1='aaa'
> $ echo "${VAR2@A}"
> declare -a VAR2='aaa'
Well, that looks a bit off.
$ VAR2=(aaa bbbb)
$ echo "${VAR2@A}"
declare -a VAR2='aaa'
$ echo "${VAR2[@]@A}"
declare -a VAR2=([0]="aaa" [1]="bbbb")
I suggest next time, do your tests with a multi-element indexed array,
since it will make it obvious when your test case is incorrectly
printing only one element.
> $ echo "${VAR3@A}"
>
> $
>
> --
> Arfrever Frehtes Taifersar Arahesis
>
--
Eli Schwartz
Bug Wrangler and Trusted User
signature.asc
Description: OpenPGP digital signature