develooper Front page | perl.perl5.porters | Postings from September 2018

[perl #133463] perl -e "open A, 'dir|';print $?" should be 0 onMSWin32

From:
Tony Cook via RT
Date:
September 6, 2018 01:37
Subject:
[perl #133463] perl -e "open A, 'dir|';print $?" should be 0 onMSWin32
Message ID:
rt-4.0.24-13769-1536197845-1866.133463-15-0@perl.org
On Tue, 21 Aug 2018 13:06:20 -0700, Vadim.Konovalov@dell.com wrote:
> For this simple one-liner
>   perl -e "open A, 'dir|';print $?"
> different perl versions on Win32 mostly output -1
> but not all (5.8.4 outputs 0)
> 
> D:\apps\perl-old\perl584\bin>perl -e "open A, 'dir|';print $?"
> 0
> D:\apps\perl-old\perl5121\bin>perl -e "open A, 'dir|';print $?"
> -1
> D:\apps\perl-old\perl-5.16.0>perl -e "open A, 'dir|';print $?"
> -1
> D:\apps\perl-old\perl-5-004-02>perl -e "open A, 'dir|';print $?"
> -1
> D:\apps\perl-old\perl5_005_03>perl -e "open A, 'dir|';print $?"
> -1
> D:\apps\perl-old\perl561>perl -e "open A, 'dir|';print $?"
> -1
> D:\apps\perl-5.28.0\perl\bin>perl -e "open A, 'dir|';print $?"
> -1
> 
> on Cygwin this outputs 0 as expected, as well as on linux freebsd etc
> 
> reading "perldoc perlvar" gives me think that it should output 0

Possibly introduced (at least for NT-ish systems) by 40c7cc6dda502ce0119863824290b6aa3c979bb0.

I don't see anything in the documentation for open() nor for $?
indicating that $? is modified by open(), nor that it's modified
by open.

The behaviour you're seeing on Linux isn't that open is setting $? to 0, it just isn't touching it:

  $ perl -le '$? = -1; open F, "ls |"; print $?'
  -1

So perhaps pp_open() should be preserving PL_statusvalue ($?).

Not that I can see much reason for you to be checking $? after a successful open.

Tony

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=133463



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About