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

Re: [BUG] In reference to patch 39815, about (z) flag and $( parse error



On Oct 15,  4:31pm, Sebastian Gniazdowski wrote:
}
} It's rather not a bug after all. The cause is an apostrophe in comment.
} 
} # '
} () {
}         au_arr+=(expand-absolute-path up-line-or-beginning-search)
} }

Interesting.

This points out a different issue:

torch% setopt cshjunkiequotes
torch% printf '<%s>\n' ${(z)buf}
<#>
<'>
torch% 

Should the parse abort there?  Other parse errors don't cause (z) to
fail when cshjunkiequotes is not set.  (At least it should not abort
silently, but (z) suppresses parse error messages.)

If the parse should not abort, should it act as if cshjunkiequotes
were not set, or should it treat the line from the quote to the end
as a STRING token and then resume parsing on the next line?

The patch below implements that latter.


diff --git a/Src/lex.c b/Src/lex.c
index e0190af..c2a5966 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -1291,7 +1291,9 @@ gettokstr(int c, int sub)
 		ALLOWHIST
 		if (c != '\'') {
 		    unmatched = '\'';
-		    peek = LEXERR;
+		    /* Not an error when called from bufferwords() */
+		    if (!(lexflags & LEXFLAGS_ACTIVE))
+			peek = LEXERR;
 		    cmdpop();
 		    goto brk;
 		}
@@ -1313,7 +1315,9 @@ gettokstr(int c, int sub)
 	    cmdpop();
 	    if (c) {
 		unmatched = '"';
-		peek = LEXERR;
+		/* Not an error when called from bufferwords() */
+		if (!(lexflags & LEXFLAGS_ACTIVE))
+		    peek = LEXERR;
 		goto brk;
 	    }
 	    c = Dnull;
@@ -1350,7 +1354,9 @@ gettokstr(int c, int sub)
 	    cmdpop();
 	    if (c != '`') {
 		unmatched = '`';
-		peek = LEXERR;
+		/* Not an error when called from bufferwords() */
+		if (!(lexflags & LEXFLAGS_ACTIVE))
+		    peek = LEXERR;
 		goto brk;
 	    }
 	    c = Tick;
@@ -1392,7 +1398,7 @@ gettokstr(int c, int sub)
 	return LEXERR;
     }
     hungetc(c);
-    if (unmatched)
+    if (unmatched && !(lexflags & LEXFLAGS_ACTIVE))
 	zerr("unmatched %c", unmatched);
     if (in_brace_param) {
 	while(bct-- >= in_brace_param)



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