Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: pws-19: minor syntactic innovation
- X-seq: zsh-workers 6413
- From: Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>
- To: "Zsh hackers list" <zsh-workers@xxxxxxxxxxxxxx>
- Subject: Re: PATCH: pws-19: minor syntactic innovation
- Date: Tue, 01 Jun 1999 10:21:40 +0200
- In-reply-to: ""Andrej Borsenkow""'s message of "Tue, 01 Jun 1999 10:23:48 DFT." <00eb01beabf7$4edde7b0$21c9ca95@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
"Andrej Borsenkow" wrote:
> > What's the parse of something like ${(f)"${"$(typeset)"}"} ? It doesn't
> > seem to be the `obvious' one -- it appears that the quoted strings are
> > actually nesting, because of the enclosing braces, which is something
> > pretty radically new. (I may be wrong.) Is this a good thing?
>
> No. It breaks the basic shell grammar. The main problem is, it can have
> unexpected side effects when running in sh or ksh compatibility mode - and
> this is definitely bad thing.
This isn't due to the change I made, it simply showed up because of that.
The cause is dquote_parse(), which is doing brace-counting; in other words,
it rejects the second `"' as the end of the quoted string because it
detected the ${. So this behaviour seems to be entirely deliberate.
I'm not so sure it's either new or wrong. I discovered in an
initialisation file here,
if [ -n "${BASH_VERSION:-""}" ]; then
which is obviously for bash rather than zsh (and works in bash, too). If
the quotes don't parse in a nested fashion, this is meaningless, and
wouldn't parse in zsh because it always matches up braces, including inside
quotes.
Furthermore,
bash$ echo "${FOO"<RET>
>
It's at the continuation prompt, so it's still parsing after the brace,
just like zsh (bash will report an error if it ever gets the remaining
`"}"', though). sh reports `bad subsitution' at this point, however; but
even so, I can't think offhand of a working piece of sh code which would be
broken by this feature. The fact that bash works happily as sh tends to
reinforce that view.
--
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
Messages sorted by:
Reverse Date,
Date,
Thread,
Author