bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

variable indirection and arrays ?


From: Jorma Laaksonen
Subject: variable indirection and arrays ?
Date: Wed, 20 Nov 2002 13:03:05 +0200
User-agent: Gnus/5.090007 (Oort Gnus v0.07) XEmacs/21.4 (Informed Management, mips-sgi-irix6.5)

Hello!

I cannot find any documentation that would tell me whether and how it
is possible to do variable indiriction to arrays.

This works:

bash-2.05a$ a=xxx
bash-2.05a$ b=a
bash-2.05a$ echo $a
xxx
bash-2.05a$ echo ${!b}
xxx

But this doesn't:

bash-2.05a$ a=(xxx yyy zzz)
bash-2.05a$ b=a
bash-2.05a$ echo ${a[@]}
xxx yyy zzz
bash-2.05a$ echo ${!b[@]}
xxx

(because I would like to see "xxx yyy zzz" also on the last line!)

So, I would like to refer to the whole array $a with $b but that
way it doesn't work because [@] is expanded as part of expression
b[@], not as part of a[@] after substitution !b := a .

Any solutions ?

Yours,

Jorma Laaksonen

-- 
Jorma Laaksonen                                 email: jorma.laaksonen@hut.fi
Dr. of Science in Technology, Docent            http://www.cis.hut.fi/jorma/
Laboratory of Computer and Information Science  tel. +358-9-4513269
Helsinki University of Technology               fax. +358-9-4513277
P.O.Box 5400, Fin-02015 HUT, Finland            mob. +358-50-3058719




reply via email to

[Prev in Thread] Current Thread [Next in Thread]