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

Re: Bug: time doesn't work on builtins



> 2024/09/04 23:32, I wrote:
> 
> % x=0; time for ((i=1; i<=10000; ++i)); do ((x+=i)); done; echo $x
> 0
> 
> The for loop is not executed, and the time statistics is not output.

The reason that the for loop is skipped may be the following:

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;





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