zsh-workers
 help / color / mirror / code / Atom feed
* "time" and "exec" behavior
@ 2024-09-08 20:12 Bart Schaefer
  0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 2024-09-08 20:12 UTC (permalink / raw)
  To: Zsh hackers list

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);
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-09-08 20:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-08 20:12 "time" and "exec" behavior Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).