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 15157
- From: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx>
- To: "Benjamin R. Haskell" <zsh@xxxxxxxxxx>
- Subject: Re: Assign to parameter in parameter -- opposite of ${(P)name}?
- Date: Sat, 10 Jul 2010 17:44:34 +0200
- Cc: Zsh Users <zsh-users@xxxxxxx>
- In-reply-to: <alpine.LNX.2.01.1007101133060.4808@xxxxxxxxxxx> (Benjamin R. Haskell's message of "Sat, 10 Jul 2010 11:36:05 -0400 (EDT)")
- 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>
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. :)
Regards, Frank
Messages sorted by:
Reverse Date,
Date,
Thread,
Author