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

Re: [PATCH 2/2] clear the heredoc list in case par_event() fails



On Thursday, November 29, 2018 6:34:04 PM CET Peter Stephenson wrote:
> On Thu, 2018-11-29 at 17:24 +0100, Kamil Dudka wrote:
> > Since the above patch was applied, zsh exits successfully (despite it
> > reports >
> > parse error) on the attached example:
> > 
> >
> > % zsh parse-error.sh; echo $?
> > parse-error.sh:4: parse error
> > 0
> >
> >...
> >
> > cat <<EOF
> > $(print <<XXX
> > EOF
> 
> I don't think the problem is with the changed code, which is signalling the
> error as it should.  I think it's up above.
> 
> There's some slightly icky linkage between lex errors and the top level
> requiring tok to be LEXERR.  The simple fix using the existing
> signalling looks like the following.  I definitely don't think the tok =
> LEXERR has a moral right to percolate through in the way it must
> previously have been doing to avoid this, and the lexer does certainly
> have the right to update the token when signalling a parse error, so
> (famous last words) it's hard to see what could be wrong with this...
> 
> pws
> 
> diff --git a/Src/lex.c b/Src/lex.c
> index fa29da3..f43bcc7 100644
> --- a/Src/lex.c
> +++ b/Src/lex.c
> @@ -1613,6 +1613,7 @@ parsestr(char **s)
>  		zerr("parse error near `%c'", err);
>  	    else
>  		zerr("parse error");
> +	    tok = LEXERR;
>  	}
>      }
>      return err;

Thanks for the quick fix!  It seems to work perfectly.

Kamil




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