Hi,
back from vacation.
Thanks for all the responses.
Here my thoughts on the responses so far.
> What you've actually demonstrated here is that the behaviour on Unix
and VMS is equivalent. A die after a failed syscall (such as chdir)
causes a generic failure status to be passed to the operating system
when Perl exits.
Hmm, on Linux I see $? as 2 which is not generic in my point of view.
The %SYSTEM-F-ABORT looks generic and it is different from
%RMS-E-DNF which from John M's reply indicates it is not severe enough.
Fankly, I don't understand all this exit/return code mangling and I
don't think a Perl script writer needs to.
> Changing our implementation so it doesn't set errno also wouldn't
really help you because you'd still get whatever random value was in
vaxc$errno. Some of the time it would not be set and you'd get the
generic failure exit, but anything at all that sets errno could give you
a surprise value that has nothing to do with your %ENV lookup.
Another "hmm", the value in vaxc$errno shouldn't be random, or? It
should be the result of a CRTL function which sets it. But from my point
of view it should be cleared or reset to the previous value of
vaxc$errno, whenever a CRTL function is called to implement a Perl
feature, which usually does not require a CRTL function to be called.
> The value you get is an accident resulting from whatever last set
errno. This is true on any operating system. Here's bash on OS X:
>
> $ perl -e '$! = 99; $s = $ENV{X} or die qq/no such environment
variable: $!\n/;'
> no such environment variable: Not a STREAM
> $ echo $?
> 99
I see a predictable behaviour. If I set #! to 99 it is still 99 after an
attempt to retrieve a value from the hash. To me this demonstrates, that
Perl on OS X doesn't show unwanted side effects as Perl on VMS does.
> Since a lookup in %ENV is not a syscall, the value of errno is just
whatever happens to be lying around and a call to die in these
circumstances cannot produce a predictable exit status on any operating
system (as indicated in the docs I quoted previously). In the specific
case of an %ENV lookup, it's actually more predictable on VMS than it's
supposed to be.
$ perl -e "$s; defined $s or die ""undefined variable: '$!, $^E'\n"""
undefined variable: ', %SYSTEM-S-NORMAL, normal successful completion'
%SYSTEM-F-ABORT, abort
$
To me the question is still, why is errno set on VMS for $s=$ENV{X} ?
> use vmsish 'hushed';
I can even conditionalize that just for VMS or as has already been
suggested clear $!, $^E and maybe even $?, which are all workarounds
only required for VMS.
John