ksh: trap '...' exit int ... or just trap '...' exit?

ksh: trap '...' exit int ... or just trap '...' exit?

Post by Michael Wa » Mon, 29 Jul 2002 11:55:52



trap '...' exit int ...

int will cause the script to exit, so '...' get run twice:


#!/bin/ksh

trap 'print a' exit int
sleep 10

^Ca
a

But the natural exit will always causes '...' to run,
which is often not desired.

So should we always write something like

trap 'print a' exit int
...
trap - exit
exit 0
?
--
Michael Wang
http://www.unixlabplus.com/

 
 
 

1. What is this supposed to return: "trap 'exit ' 0; exit"?

Hi, UNIX shell gurus,

Please consider this program:

-----------
#!/bin/sh
trap exit 0
exit 1
-----------

What exit status is it supposed to exit with, according to POSIX?  What
exit status do most shells actually exit with?  How about for this tiny
variation:

-----------
#!/bin/sh
trap 'exit ' 0
exit 1
-----------

This one behaves differently on my system (QNX 4.11).

??????

--

Member of the League for Programming Freedom --- send e-mail for details

2. lpr with axis print servers

3. Changing 'exit' trap in ksh (Bourne compatibility)

4. Tekram SCSI-Controller

5. trap --append 'new_action' exit ?

6. Zip drive on Solaris

7. trap "action; exit" signals = trap "action" exit?

8. [TRIVIAL] 3c509.c - 1/2

9. why ./configure use '{ (exit 1); exit 1; }' ?

10. 'write' won't write; exits immediately.

11. hung after 'exit()' is called...what's it doing?

12. Exit status in trapped exit function

13. 'Trap' command and security hole