zsh-workers
 help / color / mirror / code / Atom feed
* exit_function - strange behavior
@ 2021-10-25 23:28 Tycho Kirchner
  2021-10-26  0:53 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Tycho Kirchner @ 2021-10-25 23:28 UTC (permalink / raw)
  To: Zsh hackers list

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-01  9:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25 23:28 exit_function - strange behavior Tycho Kirchner
2021-10-26  0:53 ` Bart Schaefer
2021-10-31 23:52   ` Bart Schaefer
2021-11-01  9:47     ` Tycho Kirchner

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).