From: Zoltan Hidvegi <hzoli@cs.elte.hu>
To: zsh-workers@math.gatech.edu (zsh-workers)
Subject: Re: Expansion/quoting quirks
Date: Mon, 6 Nov 1995 16:39:06 +0100 (MET) [thread overview]
Message-ID: <199511061539.QAA07497@bolyai.cs.elte.hu> (raw)
In-Reply-To: <951105102637.ZM28524@zyrcon.z-code.com> from "Barton E. Schaefer" at Nov 5, 95 10:26:37 am
> This one seems really strange to me. Why is $(foo) different from `foo`
> in ksh? I think I prefer zsh's behavior, even if it isn't compatible.
>
> $ echo $(echo '\$x')
> \$x
> $ echo `echo '\$x'`
> $x
> $
>
> Look, ksh isn't even consistent about it! Why should that $ cause a
> magically different behavior?
>
> $ echo $(echo '\x')
> \x
> $ echo `echo '\x'`
> \x
> $
Here is the relevant part from the ksh93 manual:
Command Substitution.
The standard output from a command enclosed in parentheses
preceded by a dollar sign ( $() ) or a pair of grave
accents (``) may be used as part or all of a word; trail-
ing new-lines are removed. In the second (obsolete) form,
the string between the quotes is processed for special
quoting characters before the command is executed (see
Quoting below). The command substitution $(cat file) can
be replaced by the equivalent but faster $(<file).
... Inside grave
quote marks (``), \ quotes the characters \, `, and $. If
the grave quotes occur within double quotes, then \ also
quotes the character ".
The baseline zsh implement this behaviour. However when it is invoked as sh
or ksh, it sets the glob_subst option which. But glob_subst is buggy in the
baseline, since the result of the expansion is not only globbed but also
expanded using parameter expansion.
E.g. foo='$foo' ; echo $foo
causes an infinite loop when glob_subst is set.
Cheers,
Zoltan
next prev parent reply other threads:[~1995-11-06 16:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1995-11-05 13:00 Thorsten Meinecke
1995-11-05 18:26 ` Barton E. Schaefer
1995-11-06 15:39 ` Zoltan Hidvegi [this message]
1995-11-06 17:25 ` Zoltan Hidvegi
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=199511061539.QAA07497@bolyai.cs.elte.hu \
--to=hzoli@cs.elte.hu \
--cc=zsh-workers@math.gatech.edu \
/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).