Mikael Magnusson | 24 Sep 13:56
Gravatar

syntax error despite abort [Was: simplify and if then else]

2008/9/24 Mikael Magnusson <mikachu <at> gmail.com>:
> A bit longer but arguably still simpler :)
> cd /$([[ "$LOGNAME" != davidr ]] && echo o || echo c)/inetpub/wwdev/blabla

I wanted to try if you could use anonymous functions somehow to shorten
it a bit (probably not), but I encountered this
% function foo() { } hello syntax error
zsh: correct 'hello' to 'bell' [nyae]? a
zsh: parse error near `hello'
%

There is probably some explanation for why this is so, like there is for why
I have to use my mouse to cut and paste when there's a syntax error involving
some internal keywords, but maybe it's a simple bug that can be fixed? (hah)

--

-- 
Mikael Magnusson

Peter Stephenson | 24 Sep 21:10
Favicon

Re: syntax error despite abort [Was: simplify and if then else]

On Wed, 24 Sep 2008 14:00:17 +0200
"Mikael Magnusson" <mikachu <at> gmail.com> wrote:
> % function foo() { } hello syntax error
> zsh: correct 'hello' to 'bell' [nyae]? a
> zsh: parse error near `hello'
> %
> 
> There is probably some explanation for why this is so, like there is for why
> I have to use my mouse to cut and paste when there's a syntax error involving
> some internal keywords, but maybe it's a simple bug that can be fixed? (hah)

It looks like it is.  The reason this shows up is that spell checking
simply sets a flag in the history mechanism that the line currently
being parsed isn't to be executed when it's finished.  However, I think
that if that flag is set there is no point in reporting any syntax
errors since the code isn't going to be executed.

Index: Src/parse.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/parse.c,v
retrieving revision 1.74
diff -u -r1.74 parse.c
--- Src/parse.c	11 Sep 2008 12:49:20 -0000	1.74
+++ Src/parse.c	24 Sep 2008 19:04:38 -0000
@@ -2205,12 +2205,14 @@
     for (t0 = 0; t0 != 20; t0++)
 	if (!t || !t[t0] || t[t0] == '\n')
 	    break;
-    if (t0 == 20)
-	zwarn("parse error near `%l...'", t, 20);
(Continue reading)


Gmane