zsh-workers
 help / color / mirror / code / Atom feed
* Re: is variable with variable name possible?
       [not found]   ` <BANLkTimU=NGp8eMkQKmNony3n4sR8ezreQ@mail.gmail.com>
  2011-04-05  4:09     ` is variable with variable name possible? ZyX
@ 2011-04-05  4:09     ` ZyX
  1 sibling, 0 replies; 2+ messages in thread
From: ZyX @ 2011-04-05  4:09 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1526 bytes --]

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@yahoo.fr> wrote:
> > 2011-04-04 16:25:01 +0200, Mikael Magnusson:
> >> On 4 April 2011 16:06, Stephane Chazelas <stephane_chazelas@yahoo.fr> 
wrote:
> >> > 2011-04-04 15:48:32 +0200, Jérémie Roquet:
> >> > [...]
> >> > 
> >> >> 2011/4/4 zzapper <david@tvis.co.uk>:
> >> >> > 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 #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: is variable with variable name possible?
       [not found]   ` <BANLkTimU=NGp8eMkQKmNony3n4sR8ezreQ@mail.gmail.com>
@ 2011-04-05  4:09     ` ZyX
  2011-04-05  4:09     ` ZyX
  1 sibling, 0 replies; 2+ messages in thread
From: ZyX @ 2011-04-05  4:09 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: Text/Plain, Size: 1526 bytes --]

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@yahoo.fr> wrote:
> > 2011-04-04 16:25:01 +0200, Mikael Magnusson:
> >> On 4 April 2011 16:06, Stephane Chazelas <stephane_chazelas@yahoo.fr> 
wrote:
> >> > 2011-04-04 15:48:32 +0200, Jérémie Roquet:
> >> > [...]
> >> > 
> >> >> 2011/4/4 zzapper <david@tvis.co.uk>:
> >> >> > 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 #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-04-05  4:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <Xns9EBD94C46B8C1zzappergmailcom@80.91.229.10>
     [not found] ` <20110404162824.GB9371@yahoo.fr>
     [not found]   ` <BANLkTimU=NGp8eMkQKmNony3n4sR8ezreQ@mail.gmail.com>
2011-04-05  4:09     ` is variable with variable name possible? ZyX
2011-04-05  4:09     ` ZyX

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).