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

Build a variable name from another variable?



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 -----

I get this error: bad substitution

I think the answer involves the (P) flag, as in:
echo ${${(P)baz}contents}

But that dies with the same error.

I am running Debian unstable, zsh version 4.0.9.

Thanks,
   Omen

-- 
I used up all my sick days, so I'm calling in dead.

Attachment: pgpHOjptJkjAH.pgp
Description: PGP signature



Messages sorted by: Reverse Date, Date, Thread, Author