Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Parse error (lack thereof) on incomplete loops
- X-seq: zsh-workers 43615
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- Subject: Re: Parse error (lack thereof) on incomplete loops
- Date: Sat, 6 Oct 2018 20:51:45 -0700
- Cc: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kgsu9BlhyzwgG9baWaGrt5S4g5TXDoUSYwscJ9Whysw=; b=ZQYWP9M0gARbekEGErl+MVOUmdkJPWHA0lVn73NeHZ0iS2Jg1ecmnhFAT3ox0AB5ho SMms0n5jyDgjHqFAvCXwfRqO65RfSW7yr1sKu1zRH7sAYSxF8OlbkqOYmAMnk1P7Sztv tk3YGCsOjLdU4A2KMwCVxWMHbGUnC1cIJ5fC9UPQh8W/p/Of+mhpnNR56mZ7+UGlLT36 KY3kr3UwVFWBhKvo7y2J1lSN2mxguZl06qi5QyNjFxe5WvugqnnPTdJ8NaP9Ywha03xN bioBzp6KLLcW6ZFcK9J0nNDv8gkh1cPlqI3dp3FvdRuMn/dryDnlhpvtFiF0XzzpmPyn YtQw==
- In-reply-to: <20181006192104.4a66da1a@pws-HP.localdomain>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CGME20181004154947epcas4p2441e109a2c4e060bf39f0f6925e98241@epcas4p2.samsung.com> <CAH+w=7awbwDuX2RXcB7pK6Hhbi8fjs=NvwkTAEGmY7gvNpLCqA@mail.gmail.com> <20181004163158eucas1p234a045be013b5463d8db44314ed217dc~adN28lJmq0822408224eucas1p2F@eucas1p2.samsung.com> <CAH+w=7ZLJ5iiph8jpsSiLKdhkozqH+o_kJk7=zfK3DLBegft8g@mail.gmail.com> <20181005091435eucas1p26edaafb362de339b01c3cb5780fbd108~aq5QQQ6pF1496014960eucas1p2g@eucas1p2.samsung.com> <CAH+w=7auLdphdcLBsKFsEqyRE0Ug6o+13TYOVx-KO3g9Z2QP2Q@mail.gmail.com> <20181006192104.4a66da1a@pws-HP.localdomain>
So ... I've been looking through the git history of Doc/Zsh/grammar.yo ...
On Sat, Oct 6, 2018 at 11:21 AM Peter Stephenson
<p.w.stephenson@xxxxxxxxxxxx> wrote:
>
> On Fri, 5 Oct 2018 18:47:01 -0700
> Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> > For the if, while and until commands, in both these cases the test part
> > of the loop must also be suitably delimited, such as by `[[ ... ]]' or
> > `(( ... )), else the end of the test will not be recognized.
>
> Looked at this a bit more and I have fairly major doubts about the
> documentation (although I don't mean about the intention suggested by
> Bart which does seem reaonsble).
2001-07-05 Peter Stephenson <pws@xxxxxxx>
+ * 15264: Doc/Zsh/grammar.yo: improve description of use of
+ variant complex command forms to avoid confusing the present
+ writer.
+
So apparently you've had doubts about this for a long time.
> The short versions below only work if var(sublist) is of the form `tt({)
> var(list) tt(})' or if the tt(SHORT_LOOPS) option is set.
This appears to be a reference to
item(tt(if) var(list) var(sublist))
and similar doc of "for", "repeat", and "select".
These also have the "{ list }" forms documented separately so I don't
know why the "sublist" form of while and until was never made explicit
(see guess at it below).
> so maybe that "{ list }" should really be "sublist"?
Or the form should just be added for congruence with the doc of the
other complex commands. If they'd all been there separately in the
first place, the sentence about "var(sublist) is of the form ..."
might never have been needed. It's also quite likely (I haven't dug
into this in the Src commits) that "while" and "until" originally did
NOT work with only a sublist and that they do is another accidental
feature from some even earlier parser change.
> It's also not clearly (or at all? I can't see it) documented that you
> only get the SHORT_LOOPS effect if there's no delimiter --- if you stick
> one in it looks like a normal command list which it'll just go on parsing.
True that this is not called out, but implicitly from the grammar:
var(list) var(sep) var(sublist) matches a production yielding
var(list), so if there is a var(sep) then the var(list) isn't done
yet. You have to have a grammatically concluded var(list) as the
conditional before you can tack on a var(sublist) as the body.
> Perhapse someone who may have to be Bart (I can't say I consider myself
> an expert in this having only just found out what's going on and I can't
> say anyone else is likely to, either) should suggest some words of
> wisdom to document SHORT_LOOPS as separate text rather than as part of
> the variant syntax section? I don't mind writing this up.
I may have time to take a stab at this tomorrow, can't promise. Maybe
the above is a start. I also don't presently have a computer with
"yum" installed/working.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author