Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug: TRAPEXIT not executed



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   



Messages sorted by: Reverse Date, Date, Thread, Author