Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
"time" and "exec" behavior
- X-seq: zsh-workers 53075
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: "time" and "exec" behavior
- Date: Sun, 8 Sep 2024 13:12:28 -0700
- Archived-at: <https://zsh.org/workers/53075>
- List-id: <zsh-workers.zsh.org>
Tangentially to getting time stats for builtins, I've noticed that in
bash, if execve() fails, control returns to the surrounding context,
which means among other things you can get timings for failed "exec".
Conversely in zsh "exec" is final -- if e.g. the command is not found,
an error is printed but the shell goes away anyway.
This is tricky to change because the parent shell has thrown away a
lot of context (including but not limited to whether ZLE is active)
before reaching the point of calling zexecve(). It's even a bit more
convoluted if "command -p" was used. Thoughts?
(The branch with _realexit() off the top of the following non-patch is
for commandnotfound() handling.)
diff --git a/Src/exec.c b/Src/exec.c
index 00278ac50..8aa7466f5 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -881,6 +881,10 @@ execute(LinkList args, int flags, int defpath)
_realexit();
else
zerr("command not found: %s", arg0);
+ /* This is bash behavior, but fails to restore interactive settings etc.
+ lastval = ((eno == EACCES || eno == ENOEXEC) ? 126 : 127);
+ return;
+ */
_exit((eno == EACCES || eno == ENOEXEC) ? 126 : 127);
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author