Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
trap for EXIT doesn't catch exit?
- X-seq: zsh-users 4238
- From: Michal Vitecek <M.Vitecek@xxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: trap for EXIT doesn't catch exit?
- Date: Tue, 18 Sep 2001 13:14:16 +0200
- Mail-followup-to: Michal Vitecek <fuf@xxxxxxxxxxxxxx>, zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
 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