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 an entire variable reference, in this case 'b[0]'. The idea behind that was to permit the use of an array of variable names, for instance, that could be easily referenced using indirect expansion. The following code will display "x variable y variable z variable" a=(x y z) x='x variable' y='y variable' z='z variable' echo "${!a[0]} ${!a[1]} ${!a[2]}" Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/