Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Build a variable name from another variable?
- X-seq: zsh-users 7013
- From: Philippe Troin <phil@xxxxxxxx>
- To: Omen Wild <Omen.Wild@xxxxxxxxxxxxx>
- Subject: Re: Build a variable name from another variable?
- Date: 23 Jan 2004 15:19:20 -0800
- Cc: zsh users <zsh-users@xxxxxxxxxx>
- In-reply-to: <20040123224220.GB3354@xxxxxxxxxxxxxxxxxxxxxxx>
- Mail-copies-to: nobody
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20040123224220.GB3354@xxxxxxxxxxxxxxxxxxxxxxx>
- Sender: Philippe Troin <phil@xxxxxxxx>
Omen Wild <Omen.Wild@xxxxxxxxxxxxx> writes:
> I am not totally sure what it is called, but I want to build a variable
> name dynamically, from the contents of another variable. That is, I
> have:
>
> ----- Begin script -----
> barcontents="bar contents"
> baz="bar"
>
> echo $barcontents # <---- effect I want
> echo ${${baz}contents} # <---- how I want to get there
> ----- End script -----
% t="${baz}contents"
% echo ${${(P)t}}
bar contents
Works...
i could not manage to do it without an intermediate variable.
Phil.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author