this message in context:
http://old.nabble.com/Indirect-expansion-and-arrays-tp29300541p34504291.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.
Techlive Zheng techlivezh...@gmail.com 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
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.
It does, but it doesn't
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 `!' binds to
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
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
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
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