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

Re: PATCH: completion of glob qualifiers



On Fri, 22 Feb 2008 22:06:55 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> schaefer<501> echo ${var:Oops. Bug in parse_subst_string: errflag

This certainly isn't new, and in fact I think it's overzealous
error checking.  Because we're in a context where we might not be
able to parse something (we're doing unquoting of a string which
could contain anything, not necessarily something that can be parsed),
the error should be suppressed, and indeed noerrs is on and errflag is
explicitly and unconditionally reset by the caller of this function.  So
I think we just need the debug code to respect noerrs.

I've put a comment by the definition of noerrs reminding us how it
works.  I feel such a spoilsport doing that.

(I note we end up in -default- rather than -brace-parameter- completion,
as in the case after "${(".  I suspect it might be better to handle this
in the shell code, say _dispatch, rather than trying to hack the already
horrific context parsing inside the shell.)

Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.129
diff -u -r1.129 exec.c
--- Src/exec.c	21 Feb 2008 18:27:04 -0000	1.129
+++ Src/exec.c	23 Feb 2008 18:03:29 -0000
@@ -46,7 +46,10 @@
 /**/
 int noerrexit;
 
-/* suppress error messages */
+/*
+ * noerrs = 1: suppress error messages
+ * noerrs = 2: don't set errflag on parse error, either
+ */
  
 /**/
 mod_export int noerrs;
Index: Src/lex.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/lex.c,v
retrieving revision 1.43
diff -u -r1.43 lex.c
--- Src/lex.c	17 Dec 2007 14:20:25 -0000	1.43
+++ Src/lex.c	23 Feb 2008 18:03:29 -0000
@@ -1619,7 +1619,7 @@
      * Historical note: we used to check here for olen == l, but
      * that's not necessarily the case if we stripped an RCQUOTE.
      */
-    if (c != STRING || errflag) {
+    if (c != STRING || (errflag && !noerrs)) {
 	fprintf(stderr, "Oops. Bug in parse_subst_string: %s\n",
 		errflag ? "errflag" : "c != STRING");
 	fflush(stderr);


-- 
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