Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Build a variable name from another variable?



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