Reply to message «Re: is variable with variable name possible?», sent 20:34:26 05 April 2011, Tuesday by Mikael Magnusson: > Pretty sure globsubst breaks your idea too, but fine, > > : ${(P)~~somevar::=$PWD} > > In fact, globsubst pretty much breaks every hook function i have :P. `emulate -L zsh' at the top of each function and it will be unbreakable by such options. Original message: > On 4 April 2011 18:28, Stephane Chazelas <stephane_chazelas@xxxxxxxx> wrote: > > 2011-04-04 16:25:01 +0200, Mikael Magnusson: > >> 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} > > > > [...] > > > > Try after > > > > sudo ln -s . '/*' > > cd '/*/*/*/*/*' > > setopt globsubst > > > > ;-) > > > > (if you're lucky, it won't crash your machine). > > Pretty sure globsubst breaks your idea too, but fine, > > : ${(P)~~somevar::=$PWD} > > In fact, globsubst pretty much breaks every hook function i have :P.
Attachment:
signature.asc
Description: This is a digitally signed message part.