From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: "time" and "exec" behavior
Date: Sun, 8 Sep 2024 13:12:28 -0700 [thread overview]
Message-ID: <CAH+w=7Y+dg+=dpSYGoR_eCTr_sun1nMpbyQGvqn8XPDy-n-FuA@mail.gmail.com> (raw)
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);
}
reply other threads:[~2024-09-08 20:13 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAH+w=7Y+dg+=dpSYGoR_eCTr_sun1nMpbyQGvqn8XPDy-n-FuA@mail.gmail.com' \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).