zsh-users
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-users@sunsite.auc.dk
Subject: Re: OPTARG not being set?
Date: Wed, 3 Feb 1999 08:38:10 +0100 (MET)	[thread overview]
Message-ID: <199902030738.IAA10555@beta.informatik.hu-berlin.de> (raw)


Sweth Chandramouli wrote:

> (astaroth)~1: joe='hello world'
> (astaroth)~2: bob=joe
> (astaroth)~3: echo ${joe}
> hello world
> (astaroth)~4: echo ${bob}
> joe
> (astaroth)~5: echo ${${bob}}
> joe
> (astaroth)~6: echo ${(e)bob}
> joe
> (astaroth)~7: echo "echo \${$(echo ${bob})}"
> echo ${joe}
> (astaroth)~8: `echo "echo \${$(echo ${bob})}"`
> joe
> (astaroth)~9: echo ${ZSH_VERSION}
> 3.1.5
> 
> 	i would think that #5 should print hello world,
> that #6 would explicitly cause parameter expansion and
> print hello world, and that #8 would evaluate the results
> of #7, which would be the same as typing #3, and would
> thus print hello world.

For standard 3.1.5 the syntax with an embedded ${...} inside a ${...}
is only useful if the outer ${...} contains some flags or other
modifying stuff. It will then work on the word(s) produced by the
inner${...}.
The (e) flag means the the string resulting from the whole ${...} will 
(at the end) be subject to another expansion (so if you had
bob=\$joe, it would work).
#8 irritates me, especially since:

  % $(echo "echo \${$(echo ${bob})}")

yields ${b}. This almost certainly caused by some weird quoting rules, 
which may even be documented.
Anyway, you should use eval for this:

  % eval echo "\$$bob"

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


             reply	other threads:[~1999-02-03  7:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-03  7:38 Sven Wischnowsky [this message]
  -- strict thread matches above, loose matches on Subject: below --
1999-02-03 18:35 Sweth Chandramouli
1999-02-03  8:23 Bart Schaefer
1999-02-03  8:03 Bart Schaefer
1999-02-03  3:56 Sweth Chandramouli
1999-02-02  8:52 Bernd Eggink
1999-02-02  5:54 Sweth Chandramouli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199902030738.IAA10555@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-users@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).