bug-bash
[Top][All Lists]
Advanced

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

Re: Indirect expansion and arrays


From: Dennis Williamson
Subject: Re: Indirect expansion and arrays
Date: Thu, 29 Jul 2010 19:26:05 -0500

Oops, sorry, that converts all of a to a scalar b so ${b[0]} gives "x
y z" and ${b[1]} gives nothing.

On Thu, Jul 29, 2010 at 7:16 PM, Dennis Williamson
<dennistwilliamson@gmail.com> wrote:
> To make your example work try:
>
> $ b=a[*]
>
> or
>
> $ b=a[@]
>
> Otherwise, your indirection is telling b to look at a as a scalar.
> This would give the same result:
>
> $ echo $a
> x
>
> On Thu, Jul 29, 2010 at 3:55 PM, Bernd Eggink <monoped@sudrala.de> wrote:
>> It seems that indirect expansion doesn't work with arrays:
>>
>> $ a=(x y z)
>> $ b=a
>> $ echo "${!b[0]} ${!b[1]} ${!b[2]}"
>> x
>>
>> Is that intended? The documentation isn't explicit about it.
>>
>> IMHO it would be very desirable to have a indirect expansion facility for
>> arrays. Otherwise there is only a choice between passing all elements to a
>> function, which is time-consuming, or using eval, which is cumbersome and
>> error-prone.
>>
>> Regards,
>> Bernd
>>
>> --
>> Bernd Eggink
>> http://sudrala.de
>>
>>
>



reply via email to

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