zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: [BUG] In reference to patch 39815, about (z) flag and $( parse error
Date: Sun, 15 Oct 2017 11:09:46 -0700	[thread overview]
Message-ID: <171015110946.ZM4359@torch.brasslantern.com> (raw)
In-Reply-To: <etPan.59e3712a.6d2dd5e3.98a8@zdharma.org>

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)


  reply	other threads:[~2017-10-15 18:09 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-10 15:03 Sebastian Gniazdowski
2017-10-10 16:19 ` Sebastian Gniazdowski
2017-10-11  3:49   ` Bart Schaefer
2017-10-11  6:41     ` Peter Stephenson
     [not found]   ` <etPan.59dd94f1.69ba7f51.98a8@AirmailxGenerated.am>
2017-10-11  8:31     ` Sebastian Gniazdowski
2017-10-11 14:09       ` Sebastian Gniazdowski
2017-10-11 15:07         ` Sebastian Gniazdowski
2017-10-11 17:02       ` Bart Schaefer
2017-10-12 14:54         ` Sebastian Gniazdowski
2017-10-12 15:26           ` Bart Schaefer
2017-10-12 15:50             ` Peter Stephenson
2017-10-13  7:56               ` Bart Schaefer
2017-10-13  9:36                 ` Peter Stephenson
2017-10-13 20:55                   ` Bart Schaefer
2017-10-14 14:44                     ` Sebastian Gniazdowski
2017-10-15  1:53                       ` Bart Schaefer
2017-10-15 14:31                         ` Sebastian Gniazdowski
2017-10-15 18:09                           ` Bart Schaefer [this message]
2017-10-15 18:44                             ` Daniel Shahaf
2017-10-15 19:59                               ` Bart Schaefer
2017-10-17  6:34                             ` Sebastian Gniazdowski
2017-10-13  7:53             ` Sebastian Gniazdowski
2017-10-13  8:04               ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=171015110946.ZM4359@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).