zsh-users
 help / color / mirror / code / Atom feed
* Build a variable name from another variable?
@ 2004-01-23 22:42 Omen Wild
  2004-01-23 23:19 ` Philippe Troin
  2004-01-23 23:47 ` Cosmo
  0 siblings, 2 replies; 5+ messages in thread
From: Omen Wild @ 2004-01-23 22:42 UTC (permalink / raw)
  To: zsh users

[-- Attachment #1: Type: text/plain, Size: 627 bytes --]

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 #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-01-24  2:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-23 22:42 Build a variable name from another variable? Omen Wild
2004-01-23 23:19 ` Philippe Troin
2004-01-24  0:51   ` Omen Wild
2004-01-24  2:36     ` Bart Schaefer
2004-01-23 23:47 ` Cosmo

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).