bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Funny behaviour of associative arrays


From: alex xmb ratchev
Subject: Re: Funny behaviour of associative arrays
Date: Tue, 27 Jun 2023 11:22:22 +0200

On Tue, Jun 27, 2023, 11:00 alex xmb ratchev <fxmbsw7@gmail.com> wrote:

>
>
> On Tue, Jun 27, 2023, 07:29 n952162 <n952162@web.de> wrote:
>
>> Is this correct?
>>
>>     declare -A l1
>>
>>     l1=([a]=b [c]=d)
>>     echo ${!l1[@]}
>>
>>     l1=($(echo [a]=b [c]=d))
>>     echo ${!l1[@]}
>>
>
> declare -A "l1=( $( echo [ab]=22 ) )"
> declare -A "l1+=( name content )"
> l1+=( third 33 )
> declare -p l1
> -------------------------
> declare -A l1=([ab]="22" [third]="33" [name]="content" )
>
> u need to pass it thru a shell keyword or builtin or smth , to make it
> actually parse this stuff
>
> $ bash  t4
>> c a
>> [a]=b [c]=d
>>
>> If so, why?  And how can I assign a list of members to an associative
>> array?
>>
>
mkdir -p at1/{$'\1',$'$( echo foo )'}
declare -a "recent=( $(
ls -ac --quoting-style=shell-escape at1/
) )"
rm -rf at1
declare -p recent
------------------------------
declare -a recent=([0]=$'\001' [1]="\$( echo foo )" [2]="." [3]="..")

>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]