From: Tycho Kirchner <tychokirchner@mail.de>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: exit_function - strange behavior
Date: Tue, 26 Oct 2021 01:28:12 +0200 [thread overview]
Message-ID: <8ce6fada-c1da-c64f-9eb2-ccce5250474a@mail.de> (raw)
Dear zsh-maintainers,
first of all, I'm not a mail-subscriber but please respond to this email
anyway ^_^
In the function doc for zshexit it states:
> Executed at the point where the main shell is about to exit normally.
This is not called by exiting subshells...
Having read that the following session yields a surprising result (at
least for me):
debian-dell% echo $ZSH_VERSION # Running on Debian Buster
5.8.0.2-dev
debian-dell% __zshrc_exit(){ echo "__zshrc_exit in subshell
$ZSH_SUBSHELL with $?"; }
debian-dell% zshexit_functions+=(__zshrc_exit)
debian-dell% ( echo foo )
foo
debian-dell% ( exit 123 )
__zshrc_exit in subshell 1 with 123 # <---
debian-dell%
On the other hand the exit function seems to be not called for the main
shell, when a subshell called 'exit' immediately before:
debian-dell% zsh -f -c '__zshrc_exit(){ echo "__zshrc_exit in subshell
$ZSH_SUBSHELL with $?"; }; zshexit_functions+=(__zshrc_exit); (exit 123);'
__zshrc_exit in subshell 1 with 123
debian-dell%
In case that this is desired behavior, how would one execute custom code
*only* on exit of the main-shell?
Thanks in advance
Kind regards
Tycho Kirchner
next reply other threads:[~2021-10-25 23:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-25 23:28 Tycho Kirchner [this message]
2021-10-26 0:53 ` Bart Schaefer
2021-10-31 23:52 ` Bart Schaefer
2021-11-01 9:47 ` Tycho Kirchner
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=8ce6fada-c1da-c64f-9eb2-ccce5250474a@mail.de \
--to=tychokirchner@mail.de \
--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).