Re: PERL_VMS_POSIX_EXIT (Re: Q: Can anyone explain this cursious behaviour.)

[email protected] ("John E. Malmberg") Mon, 21 Jul 2014 19:41:31 -0500
Newsgroups perl.vmsperl
Message-ID <[email protected]>
On 7/21/2014 7:06 PM, Craig A. Berry wrote:
>
> On Jul 20, 2014, at 3:50 PM, John E. Malmberg <[email protected]> wrote:
>
>> If you define PERL_VMS_POSIX_EXIT or DECC$FILENAME_UNIX_REPORT, it
>> is  supposed to behave the way that you would normally expect.
>
> That depends on what you normally expect. PERL_VMS_POSIX_EXIT should
> more or less give you posixish behavior regarding exit codes. I can't
> think of a good reason to enable it unless you are running under bash.
> DECC$FILENAME_UNIX_REPORT has nothing at all to do with exit statuses.

The perlvms documentation needs to be updated.

http://perldoc.perl.org/perlvms.html

The PERL_VMS_POSIX_EXIT needed to be 1 to get it active.  "ENABLE" did 
not work.  Perl VMS documentation only mentions "ENABLE"

> Well it certainly does something:
>
> $ define PERL_VMS_POSIX_EXIT 1 $ perl -e "$! = 66; die;" Died at -e
> line 1. $ show symbol $status $STATUS == "%X1035A212"
>
> 66 is ENOTEMPTY. 66 might be embedded in that $STATUS value
> somewhere,  transmogrified by various kinds of masking and shifting,
> but I'm late for dinner and have no time to debug it at the moment.

$ x = %x212/8
$ show sym x
   X = 66   Hex = 00000042  Octal = 00000000102

BASH-4.2$ alias perl=/perl_root/perl.exe
BASH-4.2$ perl -e \
   "\$s=\$ENV{X} or die \"no such environment variable: '\$!'\n\""
no such environment variable: 'invalid argument'
BASH-4.2$ echo $?
22

BASH-4.2$ perl -e \
   "\$s='nosuchdir'; chdir \$s or die \"Can't cd to \$s: '\$!'\n\""
Can't cd to nosuchdir: 'no such file or directory'
BASH-4.2$ echo $?
2

BASH-4.2$ uname -a
OpenVMS EISNER 0 V8.3 AlphaServer_DS20_500_MHz Alpha Alpha HP/OpenVMS

Trying the DCL examples again:

$ perl -e "$s='nosuchdir'; chdir $s or die ""Can't cd to $s: '$!, $^E'\n"""
Can't cd to nosuchdir: 'no such file or directory, %RMS-E-DNF, directory 
not found'
$ show sym $status
   $STATUS == "%X1035A012"
$ unix = %x12/8
$ show sym unix
   UNIX = 2   Hex = 00000002  Octal = 00000000002

$ perl -e "$s=$ENV{X} or die ""no such environment variable: '$!, $^E'\n"""
no such environment variable: 'invalid argument, %SYSTEM-F-NOLOGNAM, no 
logical name match'
$ show sym $status
   $STATUS == "%X1035A0B2"
$ unix = %x0b2/8
$ show sym unix
   UNIX = 22   Hex = 00000016  Octal = 00000000026

This feature setting also allows perl to spawn child perls and capture 
the original exit codes.

Regards,
-John