[tpm] Reliable exit code
antoniosun at lavabit.com
Mon Nov 21 17:08:23 PST 2011
On Mon, Nov 21, 2011 at 1:00 PM, Mike Stok <mike at stok.ca> wrote:
> On 2011-11-21, at 12:54 PM, Antonio Sun wrote:
> I want the program exit code to reflect the fact whether the pattern has
> been found or not. . .
> You can do something like
> @matches = $string =~ /.(.)./;
> And then see if @matches has any elements.
Thanks Mike. I'm following your advice and am now able to detect failed
Now there is a new problem. I found that I am not able to set the exit code.
The whole program is written in OO fashion. The executed part is in a
*derived* class. The last several lines before my code terminates are:
$ret = @matches ? 0 : 1;
$self->debug("toret: $ret", 1);
Executing the code with:
my-script; echo Ret:$?
We can clearly see that the value of '$ret' is 1, and is taken as the
script exit code; but what the exit code seen from the outside is actually
exit is supposed to exit immediately with that value. I don't have any
defined "END" routines, nor any traps, or explicitly defined class
destructors. Why my exit didn't exit with the given exit code? My perl is
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the toronto-pm