in reply to $SIG{__DIE__} overrides exit status?
Apparently, the $SIG{__DIE__} causes the program to exit with a status of zero.
No, it doesn't
>type script.pl #!/usr/bin/perl $SIG{__DIE__} = sub { die @_ }; no_such_sub(); >echo %ERRORLEVEL% 0 >perl script.pl Undefined subroutine &main::no_such_sub called at script.pl line 4. >echo %ERRORLEVEL% 255
It's whatever prints '1..1' that causes the program to exist with a status of zero.
>type script.pl #!/usr/bin/perl use strict; use warnings; use Test::More 'no_plan'; ok 1, 'this works'; $SIG{__DIE__} = sub { die @_ }; ok no_such_sub(), '... no such sub'; >echo %ERRORLEVEL% 0 >perl script.pl ok 1 - this works Undefined subroutine &main::no_such_sub called at script.pl line 9. 1..1 >echo %ERRORLEVEL% 0
You'll get very similar results if you take out the $SIG{__DIE__}. That's why you should use a plan.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: $SIG{__DIE__} overrides exit status?
by Ovid (Cardinal) on Oct 17, 2007 at 13:54 UTC |