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

Re: Bug: time doesn't work on builtins



On Thu, Sep 5, 2024 at 10:29 AM Jun. T <takimoto-j@xxxxxxxxxxxxxxxxx> wrote:
>
> When exectime() calls execpline(,slcode=*state->pc++,) (exec.c:5280),
> slcode is WC_SUBLIST with WC_SUBLIST_SIMPLE flag, and 'code' (the next
> word code) obtained by (exec.c:1677)
>     wordcode code = *state->pc++;
> is just a line number, not WC_PIPE (see parse.c:757). Then the for
> loop is skipped by (lines 1680,81)
>     if (wc_code(code) != WC_PIPE)
>         return lastval = (slflags & WC_SUBLIST_NOT) != 0;

Is this enough?  All existing tests still pass, but I wonder if
there's another way to get there.

diff --git a/Src/exec.c b/Src/exec.c
index 00278ac50..057999844 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1677,7 +1677,7 @@ execpline(Estate state, wordcode slcode, int how, int last
1)
     wordcode code = *state->pc++;
     static int lastwj, lpforked;

-    if (wc_code(code) != WC_PIPE)
+    if (wc_code(code) != WC_PIPE && !(how & Z_TIMED))
        return lastval = (slflags & WC_SUBLIST_NOT) != 0;
     else if (slflags & WC_SUBLIST_NOT)
        last1 = 0;




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