Misfortunado Farmbuyer wrote:
> I've been staring at Chet's message in
> http://www.mail-archive.com/bug-bash@gnu.org/msg01545.html
> for a while, and now I understand why my own script (doing something
> similar) was not originally working.  What I can't quite figure is what
> to change.
> 
> I'm source'ing a series of assignments of the form
>       DIRS_name1=(/foo /bar /baz)
>       DIRS_name2=(/qux /quux)
>       ....
> and earlier in the file, a list of the arbitrary 'name's are assigned.
> Running through the list of 'name's and composing the corresponding array
> variable name is no trouble, but I can't manage to indirect through to the
> entire array.  Like the person I linked to above, I keep ending up with only
> the first member of the array:

You have to remember that referencing an array variable without using
[EMAIL PROTECTED] will always return the first element of the array.  Indirect
variable expansion cannot be coerced to do otherwise.

You can always use `eval' to force the sort of double expansion you
want.  Just remember to quote everything whose evaluation you want
deferred:

DIRS_name1=( /foo /bar /baz )
DIRS_name2=( /qux /quux )

name=${1:-name1}

v=DIRS_$name

eval a='( "${'$v'[EMAIL PROTECTED]" )'

echo [EMAIL PROTECTED]

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                       Live Strong.  No day but today.
Chet Ramey, ITS, CWRU    [EMAIL PROTECTED]    http://cnswww.cns.cwru.edu/~chet/


Reply via email to