Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Assign to parameter in parameter -- opposite of ${(P)name}?
- X-seq: zsh-users 15159
- From: "Benjamin R. Haskell" <zsh@xxxxxxxxxx>
- To: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: Assign to parameter in parameter -- opposite of ${(P)name}?
- Date: Sat, 10 Jul 2010 11:54:59 -0400 (EDT)
- Cc: Zsh Users <zsh-users@xxxxxxx>
- In-reply-to: <874og7tk7x.fsf@xxxxxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <alpine.LNX.2.01.1007091908420.4808@xxxxxxxxxxx> <87fwzst9ys.fsf@xxxxxxxxxxxxxxxxxxxxxx> <alpine.LNX.2.01.1007101133060.4808@xxxxxxxxxxx> <874og7tk7x.fsf@xxxxxxxxxxxxxxxxxxxxxx>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author