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

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



On Wed, 24 Sep 2008 14:00:17 +0200
"Mikael Magnusson" <mikachu@xxxxxxxxx> 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);
-    else if (t0)
-	zwarn("parse error near `%l'", t, t0);
-    else
-	zwarn("parse error");
+    if (!(histdone & HISTFLAG_NOEXEC)) {
+	if (t0 == 20)
+	    zwarn("parse error near `%l...'", t, 20);
+	else if (t0)
+	    zwarn("parse error near `%l'", t, t0);
+	else
+	    zwarn("parse error");
+    }
     if (!noerr && noerrs != 2)
 	errflag = 1;
 }


-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



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