Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Parse error (lack thereof) on incomplete loops



On Sat, 6 Oct 2018 12:15:19 +0100
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> But that's not what's implemented --- it just calls the code to parse
> what the shell refers to as a "sublist", which is a component of the
> normal parse tree.  There's never been any special short-loops code,
> despite what the doc claims.  Hence there's no question, in general,
> of throwing a syntax error if it isn't in the above form (unless
> SHORT_LOOPS is unset).

Hence, in fact, the following is the best we're going to be able to do
without a rewrite.

In summary, the current implementation isn't sufficiently restricted
that attempting to keep it in check in terms of empty command lists
makes sense --- but for the same reason you shouldn't be relying on that
behaviour.

pws

diff --git a/Doc/Zsh/grammar.yo b/Doc/Zsh/grammar.yo
index d2c7cd29c..11326586e 100644
--- a/Doc/Zsh/grammar.yo
+++ b/Doc/Zsh/grammar.yo
@@ -409,6 +409,12 @@ tt(for), tt(repeat), tt(case) and tt(select) commands no such special form
 for the arguments is necessary, but the other condition (the special form
 of var(sublist) or use of the tt(SHORT_LOOPS) option) still applies.
 
+Note that use of the tt(SHORT_LOOPS) option is currently implemented
+loosely in the shell, so that no check of the form of the condition is made
+before attempting to parse the subsequent command list.  This means that
+other forms not documented below may be allowed; these should not be relied
+on.
+
 startitem()
 item(tt(if) var(list) tt({) var(list) tt(}) [ tt(elif) var(list) tt({) var(list) tt(}) ] ... [ tt(else {) var(list) tt(}) ])(
 An alternate form of tt(if).  The rules mean that



Messages sorted by: Reverse Date, Date, Thread, Author