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

Re: is variable with variable name possible?



On 4 April 2011 16:06, Stephane Chazelas <stephane_chazelas@xxxxxxxx> wrote:
> 2011-04-04 15:48:32 +0200, Jérémie Roquet:
> [...]
>> 2011/4/4 zzapper <david@xxxxxxxxxx>:
>> > somevar=$(pwd)
>> >
>> > but I want somevar to be a variable name
>>
>> $ eval "$somevar=$(pwd)"
> [...]
>
> No!
>
> eval "$somevar=\$(pwd)"
> or
> eval "$somevar=\$PWD"
>
>
> Or think of what would happen if $PWD was "/tmp/x;rm -rf /home"

How do you feel about this?
: ${(P)somevar::=$PWD}

-- 
Mikael Magnusson



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