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

[PATCH] ? Parse error does not always set $? (Was: Bug? Output not flushed?)



On Fri, Sep 15, 2023 at 10:30 AM Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> Unless something is actually aborting the $(...)

Ah, part of the problem is upstream.

Is there any reason parse_string() should be discarding errflag?  All
tests still pass with this change:

diff --git a/Src/exec.c b/Src/exec.c
index 3a8b3e951..f6902fd39 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -286,6 +286,7 @@ parse_string(char *s, int reset_lineno)
 {
     Eprog p;
     zlong oldlineno;
+    int xerrflag;

     zcontext_save();
     inpush(s, INP_LINENO, NULL);
@@ -299,7 +300,9 @@ parse_string(char *s, int reset_lineno)
     lastval = 1;
     strinend();
     inpop();
+    xerrflag = errflag;
     zcontext_restore();
+    errflag = xerrflag;
     return p;
 }

That's not the only thing that was needed for the original nofork
problem, but the rest isn't relevant here.




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