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.
In reply to Re: $SIG{__DIE__} overrides exit status?
by ikegami
in thread $SIG{__DIE__} overrides exit status?
by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |