Exception-Class - Re: How to Control Exit Values?

Posted on Tue Mar 14 19:48:12 2006 by je44ery in response to 1870 (See the whole thread of 5)
Re: How to Control Exit Values?

OK, this follow-up to to show that my exit-0-on-exception was not a problem with Exception::Class nor die. I was getting exit values of 0 for 3 different reasons. I hunted them all down, and it was all my fault.

1. This one is embarassing. When I was testing my code, firing from the hip on the command line, you might say, I did this:

my_prog.pl 2>&1 | tee /tmp/my_prog.out

Of course, then I did echo $? I was getting the return value of tee! Doh!

2. I was using rsh on some commands. rsh does NOT return the exit value of the command it ran, but it returns 0 if it was able to run a command at all, even if that command returned non-zero. You must come up with a workaround to acquire the exit value of an rshed command.

3. This one actually involved my Perl code. In some scripts, I was using END{} subroutines, and I was not handing off the bad exit value. So the exit value of my perl progran during an exception was 0 if my last command in the END{} sub was good.

Write a response