Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug: time doesn't work on builtins
- X-seq: zsh-workers 53068
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: "Jun. T" <takimoto-j@xxxxxxxxxxxxxxxxx>
- Cc: zsh-workers@xxxxxxx
- Subject: Re: Bug: time doesn't work on builtins
- Date: Thu, 5 Sep 2024 17:10:31 -0700
- Archived-at: <https://zsh.org/workers/53068>
- In-reply-to: <20C9A9EE-49A5-4A58-AA00-136A5D221331@kba.biglobe.ne.jp>
- List-id: <zsh-workers.zsh.org>
- References: <CAA=-s3w0wsH7xkS58JS0AbGdOoihYxq+cKEpVomFU_f1_w-ynQ@mail.gmail.com> <CAH+w=7a3BuQnPMa5YEy8n8ZNSNNoYNKLL9Aki5iCSPKbTyn5eQ@mail.gmail.com> <CAA=-s3z3YMho0a4A3H4h3o75oY1fR36w2zz83zQKjyPi3mSTpQ@mail.gmail.com> <CAH+w=7ZZ3frU9OjpkOmHzvL6Ws0YQPE=_JK+izmRR+gEcvSsDg@mail.gmail.com> <CAH+w=7ZpU-QCFAfPYvBFQvUnfekV35c3B_j7eoWvo8MokJ0Ncw@mail.gmail.com> <20C9A9EE-49A5-4A58-AA00-136A5D221331@kba.biglobe.ne.jp>
On Wed, Sep 4, 2024 at 7:33 AM Jun. T <takimoto-j@xxxxxxxxxxxxxxxxx> wrote:
>
> The followings still give no time statistics:
>
> % time x=1
> % time x=$(date)
Hm, that's because we're taking the code path marked /* Empty command
*/ in execcmd_exec().
I think the only relevant case is around addvars() but can't be sure;
does anyone know a straightforward way to conditionally suppress the
child times in the case where the right-hand-side does not fork?
(Hand-fuzzed patch follows)
diff --git a/Src/exec.c b/Src/exec.c
index 00278ac50..c2f813078 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3381,7 +3386,11 @@ execcmd_exec(Estate state, Execcmd_params eparams,
if (varspc) {
/* Make sure $? is still correct for assignment */
lastval = old_lastval;
+ if (how & Z_TIMED)
+ shelltime(&shti, &chti, &then, 0);
addvars(state, varspc, 0);
+ if (how & Z_TIMED)
+ shelltime(&shti, &chti, &then, 1);
}
if (errflag)
lastval = 1;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author