zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: zshexit hook
@ 2006-11-08 18:04 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2006-11-08 18:04 UTC (permalink / raw)
  To: Zsh hackers list

I think, now we have proper hooks, we need a hook on exit, since the
same issues can occur with TRAPEXIT as with precmd etc.; also it
means something different within a function, so always feels like a bit
of a hack.

The code is now trivial (and won't cause an endless loop any more).
I've called the zshexit; can anyone think of a better name,
i.e. something memorable which won't clash with user functions?

Index: Doc/Zsh/func.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/func.yo,v
retrieving revision 1.13
diff -u -r1.13 func.yo
--- Doc/Zsh/func.yo	8 Nov 2006 10:38:05 -0000	1.13
+++ Doc/Zsh/func.yo	8 Nov 2006 18:03:24 -0000
@@ -203,6 +203,14 @@
 elided); the third argument contains the full text that is being
 executed.
 )
+findex(zshexit)
+vindex(zshexit_functions)
+item(tt(zshexit))(
+Exited at the point where the main shell is about to exit normally.
+This is not called by exiting subshells, nor when the tt(exec)
+precommand modifier is used before an external command.  Also, unlike
+tt(TRAPEXIT), it is not called when functions exit.
+)
 item(tt(TRAP)var(NAL))(
 cindex(signals, trapping)
 cindex(trapping signals)
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.167
diff -u -r1.167 builtin.c
--- Src/builtin.c	8 Nov 2006 17:43:32 -0000	1.167
+++ Src/builtin.c	8 Nov 2006 18:03:27 -0000
@@ -4436,6 +4436,7 @@
     }
     if (sigtrapped[SIGEXIT])
 	dotrap(SIGEXIT);
+    callhookfunc("zshexit", NULL, 1);
     runhookdef(EXITHOOK, NULL);
     if (opts[MONITOR] && interact && (SHTTY != -1)) {
        release_pgrp();

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php


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

only message in thread, other threads:[~2006-11-08 18:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-08 18:04 PATCH: zshexit hook Peter Stephenson

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