zsh-users
 help / color / mirror / code / Atom feed
From: Omen Wild <Omen.Wild@Dartmouth.EDU>
To: zsh users <zsh-users@sunsite.dk>
Subject: Build a variable name from another variable?
Date: Fri, 23 Jan 2004 17:42:20 -0500	[thread overview]
Message-ID: <20040123224220.GB3354@descolada.dartmouth.edu> (raw)

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

             reply	other threads:[~2004-01-23 22:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-23 22:42 Omen Wild [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040123224220.GB3354@descolada.dartmouth.edu \
    --to=omen.wild@dartmouth.edu \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).