Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Assign to parameter in parameter -- opposite of ${(P)name}?



On Fri, Jul 9, 2010 at 4:17 PM, Benjamin R. Haskell <zsh@xxxxxxxxxx> 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?

Your first attempt wasn't complicated enough, but your second attempt
was too complicated. :-)

% name=foo
% : ${(P)name::=something}
% print $foo
something
% print $name
foo

The (P)name is interpreted before the ::= so you don't need nested expansion.



Messages sorted by: Reverse Date, Date, Thread, Author