zsh-workers
 help / color / mirror / code / Atom feed
* Bug: TRAPEXIT not executed
@ 2000-06-03 13:29 Bernd Eggink
  2000-06-03 15:59 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Bernd Eggink @ 2000-06-03 13:29 UTC (permalink / raw)
  To: Zsh Workers

When the following script exits, TRAPEXIT doesn't get executed:

    function TRAPEXIT
    {
       print BYE
    }

    function f
    {
       print f
    }

    f

However, if function f is *not* called, TRAPEXIT gets executed. 

Regards,
Bernd

-- 
Bernd Eggink
Regionales Rechenzentrum der Uni Hamburg
eggink@uni-hamburg.de
http://www.rrz.uni-hamburg.de/eggink/BEggink.html


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

* Re: Bug: TRAPEXIT not executed
  2000-06-03 13:29 Bug: TRAPEXIT not executed Bernd Eggink
@ 2000-06-03 15:59 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2000-06-03 15:59 UTC (permalink / raw)
  To: Bernd Eggink, Zsh Workers

On Jun 3,  3:29pm, Bernd Eggink wrote:
} Subject: Bug: TRAPEXIT not executed
}
} When the following script exits, TRAPEXIT doesn't get executed:
} 
}     function TRAPEXIT
}     {
}        print BYE
}     }
} 
}     function f
}     {
}        print f
}     }
} 
}     f

Hmm, it works if you put "setopt localtraps" at the top.  So the problem
is that the special handling for the EXIT trap, described by the comment
in starttrapscope(), is not happening.

This must have been introduced back in 9267; the following seems to fix.

Index: Src/signals.c
===================================================================
@@ -751,7 +751,7 @@
      * one, to aid in removing this one.  However, if there's
      * already one at the current locallevel we just overwrite it.
      */
-    if (isset(LOCALTRAPS) && locallevel &&
+    if ((isset(LOCALTRAPS) || sig == SIGEXIT) && locallevel &&
 	(!trapped || locallevel > (sigtrapped[sig] >> ZSIG_SHIFT)))
 	dosavetrap(sig, locallevel);
 

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

end of thread, other threads:[~2000-06-03 16:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-06-03 13:29 Bug: TRAPEXIT not executed Bernd Eggink
2000-06-03 15:59 ` Bart Schaefer

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