Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
exit_function - strange behavior
- X-seq: zsh-workers 49526
- From: Tycho Kirchner <tychokirchner@xxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: exit_function - strange behavior
- Date: Tue, 26 Oct 2021 01:28:12 +0200
- Archived-at: <https://zsh.org/workers/49526>
- List-id: <zsh-workers.zsh.org>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author