help-bash
[Top][All Lists]
Advanced

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

Re: is there a way to assign indexed arrays like the new assoc arrays wa


From: Alex fxmbsw7 Ratchev
Subject: Re: is there a way to assign indexed arrays like the new assoc arrays way without [..]= typing ?
Date: Sat, 13 Mar 2021 01:18:19 +0100

the idea was, its way easier to make up an array for "${arr[@]}" expanding
as content of the idx array in question..

well ok modding the strings to contain [..]= format is not so hard either,
but its way more work

peace

On Fri, Mar 12, 2021 at 11:11 PM Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com>
wrote:

> declare -A assoc=( key1 'val 1' 'key 2' 'val 2' ) ; declare -p assoc
> declare -A assoc=(["key 2"]="val 2" [key1]="val 1" )
>
> for the second, well i was asking, guess it doesnt exist yet
> and im not familiar enough with bash.c to really have a good answer to that
> maybe implent = related operators that would define the format of the
> assignment
>
> declare idx=( 0 null 1 one ) ; declare -p idx
> declare -a idx=([0]="0" [1]="null" [2]="1" [3]="one")
>
> btw i thought i must declare >> -a << the array ? hm :)
>
> On Fri, Mar 12, 2021 at 11:05 PM Eli Schwartz <eschwartz@archlinux.org>
> wrote:
>
>> On 3/12/21 4:56 PM, Alex fxmbsw7 Ratchev wrote:
>> > i agree, but it could the same way be with indexed arrays for simplified
>> > use, but its already taken by every ( ..arg.. ) is a value, not key
>> > i just say it would be useful if it allowed similiar like arr=( key val
>> > key2 val ) just the keys of course would been positive numbers only
>>
>> What is the meaning of
>>
>> declare -A assoc=( key1 val1 key2 val2 )
>>
>> previous to its ability to assign key/value pairs? Did it error out? How
>> did it treat each element?
>>
>> ...
>>
>> What is the meaning of
>>
>> declare indexed=( 0 val1 1 val2 )
>>
>> Does it error out? How does it treat each element?
>>
>> How would you propose implementing this feature request, without
>> changing the way existing scripts work?
>>
>> --
>> Eli Schwartz
>> Arch Linux Bug Wrangler and Trusted User
>>
>>


reply via email to

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