Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Expansion/quoting quirks
- X-seq: zsh-workers 536
- From: Zoltan Hidvegi <hzoli@xxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx (zsh-workers)
- Subject: Re: Expansion/quoting quirks
- Date: Mon, 6 Nov 1995 16:39:06 +0100 (MET)
- In-reply-to: <951105102637.ZM28524@xxxxxxxxxxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author