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

trap for EXIT doesn't catch exit?



 greetings,

 in one of my zsh programs i'm creating a number of temporary files which
 should be removed when the program execution stops or an error occurs
 and i call 'exit'.

 however after having specified 'trap CleanUp EXIT' the clean-up
 function is not called when 'exit' inside a function is executed.

 an example program (test.sh):
 ----start----
    #!/bin/zsh

    function CleanUp()
    {
	rm -f tempfile
    } 

    function WillExit()
    {
	exit
    }


    trap CleanUp EXIT
    touch tempfile
    WillExit
 ----end----

 $ chmod +x test.sh
 $ ./test.sh
 $ ls tempfile
 tempfile
 $

 in my understanding the CleanUp() function should be called, evidently
 it's not. what's wrong here?
 
	thanks for your help,
-- 
			fuf


------------------------------ na IRC -------------------------------------
 BillGates [bgates@xxxxxxxxxxxxxxxxx] has joined #LINUX
 ...
 mode/#linux [+b BillGates!*@*] by DoDad
 BillGates was kicked off #linux by DoDad (banned: We see enough of Bill
          Gates already.)
 



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