Re: Indirect expansion and arrays

2012-10-02 Thread Techlive Zheng
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.

Re: Indirect expansion and arrays

2012-10-02 Thread Andreas Schwab
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

Re: Indirect expansion and arrays

2012-10-02 Thread Chet Ramey
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

Re: Indirect expansion and arrays

2010-08-02 Thread Chet Ramey
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

Re: Indirect expansion and arrays

2010-07-30 Thread Greg Wooledge
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

Indirect expansion and arrays

2010-07-29 Thread Bernd Eggink
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

Re: Indirect expansion and arrays

2010-07-29 Thread Dennis Williamson
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

Re: Indirect expansion and arrays

2010-07-29 Thread Dennis Williamson
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