On 10/2/12 7:38 AM, Techlive Zheng wrote:
>
>
>> On 7/29/10 4:55 PM, Bernd Eggink 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.
Techlive Zheng writes:
> Combine with Chet Ramey's reply, a strucure like below would work.
>
> $ c=(a[0] a[1] a[2])
Careful. The elements are subject to filename expansion, so you need to
quote them to be safe.
Andreas.
--
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA
> On 7/29/10 4:55 PM, Bernd Eggink 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.
> It does, but it doesn't work in the way yo
On 29.07.2010 22:55, Bernd Eggink 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 arr
On 7/29/10 4:55 PM, Bernd Eggink 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.
It does, but it doesn't work in the way you are trying. The `!'
On Thu, Jul 29, 2010 at 10:55:51PM +0200, Bernd Eggink wrote:
> It seems that indirect expansion doesn't work with arrays:
ksh93 has a feature called nameref:
myfunc() {
nameref ref=$1
echo "array $1 has ${#ref[*]} elements"
}
I wouldn't mind seeing this in bash, though I'm not going to at
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
wrote:
> To make your example work try:
>
> $ b=a[*]
>
> or
>
> $ b...@]
>
> Otherwise, your indirection is telling b to look at a as a scalar.
To make your example work try:
$ b=a[*]
or
$ b...@]
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 wrote:
> It seems that indirect expansion doesn't work with arrays:
>
> $ a=(x y z