zsh-users
 help / color / mirror / code / Atom feed
* Double Evaluation Question (not in FAQ)
@ 2006-09-04  6:18 Com MN PG P E B Consultant 3
  2006-09-04  6:28 ` Stephane Chazelas
  0 siblings, 1 reply; 2+ messages in thread
From: Com MN PG P E B Consultant 3 @ 2006-09-04  6:18 UTC (permalink / raw)
  To: zsh-users Mailinglist

Assuming that variables are assigned in the following way:

  x=abc
  y=def
  z='$x   $y' # Note: Single Quotes!

How could I write an expression, which "evaluates" $z, in
that it would return "abc   def"? The simple

   eval "echo $z" 

would not work here, because it would not
preserve the spaces.

   eval "echo \"$z\""

would indeed do the job, but I consider this a very ugly
solution because of the nested quoting. Does anyone know 
a more elegant alternative?

Ronald
-- 
Ronald Fischer (phone +49-89-63676431)
mailto:mn-pg-p-e-b-consultant-3.com@siemens.com



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

* Re: Double Evaluation Question (not in FAQ)
  2006-09-04  6:18 Double Evaluation Question (not in FAQ) Com MN PG P E B Consultant 3
@ 2006-09-04  6:28 ` Stephane Chazelas
  0 siblings, 0 replies; 2+ messages in thread
From: Stephane Chazelas @ 2006-09-04  6:28 UTC (permalink / raw)
  To: zsh-users Mailinglist

On Mon, Sep 04, 2006 at 08:18:19AM +0200, Com MN PG P E B Consultant 3 wrote:
> Assuming that variables are assigned in the following way:
> 
>   x=abc
>   y=def
>   z='$x   $y' # Note: Single Quotes!
> 
> How could I write an expression, which "evaluates" $z, in
> that it would return "abc   def"? The simple
> 
>    eval "echo $z" 
> 
> would not work here, because it would not
> preserve the spaces.
[...]

print -r -- ${(e)z}

-- 
Stéphane


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

end of thread, other threads:[~2006-09-04  6:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-04  6:18 Double Evaluation Question (not in FAQ) Com MN PG P E B Consultant 3
2006-09-04  6:28 ` Stephane Chazelas

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).