Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

shell scripting

Name: Anonymous 2010-01-26 5:45

sup

im using 'exit 1' in a 'case' construct.
im also using 'trap' to delete some tmp data.
the problem is, that 'trap' isn't triggered by 'exit 1'. trap works though if i send ctrl-z.
why is that?
btw, my trap:
trap "rm $TMP; exit 1" 1 2 15

Name: Anonymous 2010-01-26 5:45

it should be ctrl-c of course.

Name: Anonymous 2010-01-26 6:12

[underlined]power[/underlined] bump

Name: Anonymous 2010-01-26 6:39

>>3
HIBT?

Name: Anonymous 2010-01-26 6:41

>>4
why so sage?

Name: Anonymous 2010-01-26 6:44

>>5
why so /b/?

Name: Anonymous 2010-01-26 6:53

>>6
why so mad?

Name: >>4 2010-01-26 6:59

>>6
It seems we've got outselves an imageboard individual in here[1].

____________________
[1] - >>5

Name: Anonymous 2010-01-26 9:51

>>1
HOW ABOUT YOU READ THE FUCKING HELP TEXT

Name: Anonymous 2010-01-26 23:02

>>1
Why would trap trap exit 1? Trap traps signals. Exit does not send a signal; it just exits.

Better way is to define an error handler.

function cleanup {
  rm -f $TMP
}
function errorexit {
  cleanup
  exit 1
}
trap errorexit SIGHUP SIGINT SIGTERM


Now call errorexit instead of exit 1.

Name: Anonymous 2010-01-27 3:37

>>10
HOW ABOUT YOU READ THE FUCKING HELP TEXT

Name: Anonymous 2010-01-27 6:25

>>10
How could trap trap, trap trap trap if trap trap could trap trap?

Name: Anonymous 2010-01-27 6:26

>>12
It's a trap!

Don't change these.
Name: Email:
Entire Thread Thread List