From: "Benjamin R. Haskell" <zsh@benizi.com>
To: Frank Terbeck <ft@bewatermyfriend.org>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Assign to parameter in parameter -- opposite of ${(P)name}?
Date: Sat, 10 Jul 2010 11:54:59 -0400 (EDT) [thread overview]
Message-ID: <alpine.LNX.2.01.1007101153270.4808@hp.internal> (raw)
In-Reply-To: <874og7tk7x.fsf@ft.bewatermyfriend.org>
On Sat, 10 Jul 2010, Frank Terbeck wrote:
> Benjamin R. Haskell wrote:
> > On Sat, 10 Jul 2010, Frank Terbeck wrote:
> >> Benjamin R. Haskell wrote:
> >> > It's the end of the week, and I'm tired, so I'm sure I'm
> >> > completely overlooking something obvious, but how do you *assign*
> >> > to a parameter whose name is in a parameter?
> >> [...]
> >> > Do I need to resort to 'eval'?
> >>
> >> % typeset foobar=baz
> >> % print ${foobar}
> >> baz
> >>
> >
> > I was tired... but not thaaat tired... :-)
> >
> > Using different variable names, I was looking for:
> >
> > name=xyzzy
> > value=asdf
> >
> > # <-- something that doesn't involve the string xyzzy
> >
> > echo $xyzzy # echoes 'asdf'
>
> Yes. But the "foobar=baz" part is just a parameter to a builtin
> command. Hence you can do this:
>
> % name=foobar
> % typeset ${name}=baz
> % print $foobar
> baz
>
> I thought that was what you were after. If not, I must have
> misunderstood the problem entirely. :)
Ah, gotcha. I hadn't seen Julius's reply yet, and didn't take the
logical step on my own.
--
Thanks,
Ben
next prev parent reply other threads:[~2010-07-10 15:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-09 23:17 Benjamin R. Haskell
2010-07-10 1:13 ` Frank Terbeck
2010-07-10 15:36 ` Benjamin R. Haskell
2010-07-10 15:44 ` Frank Terbeck
2010-07-10 15:54 ` Benjamin R. Haskell [this message]
2010-07-10 14:57 ` Julius Plenz
2010-07-10 15:52 ` Benjamin R. Haskell
2010-07-10 17:39 ` Bart Schaefer
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=alpine.LNX.2.01.1007101153270.4808@hp.internal \
--to=zsh@benizi.com \
--cc=ft@bewatermyfriend.org \
--cc=zsh-users@zsh.org \
/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).