develooper Front page | perl.perl5.porters | Postings from July 2021

pipe-open on Windows tells porkies about failures

Thread Next
From:
David Cantrell
Date:
July 8, 2021 10:08
Subject:
pipe-open on Windows tells porkies about failures
Message ID:
20210708095033.GA20545@bytemark.barnyard.co.uk
I got an interesting CPAN-testers failure recently:
  https://www.cpantesters.org/cpan/report/adf8485b-6c60-1014-b56d-e7e4bfdedd6e
  https://www.cpantesters.org/cpan/report/962cc9a4-6bf5-1014-ac30-9c81686fcd47

for this code:
  https://metacpan.org/release/DCANTRELL/CPAN-FindDependencies-3.07/source/t/multi.t

As you can see, the test attempts to divine whether `bzip2` is installed
by using a pipe-open, and if that fails it will skip the tests. This
works just fine on Unix-a-likes, skipping the tests as appropriate, and
all the code works on Windows if `bzip2` is installed:
  https://ci.appveyor.com/project/DrHyde/perl-modules-cpan-finddependencies/builds/39877167/job/e3fiy4xsu1xcd1o6

But on Windows if `bzip2` is *not* installed then the 2-arg form of
open() returns true even when the open() fails. I am led to believe that
this is because in this case perl constructs a `cmd` wrapper around
`bzip2`, and `cmd` can be executed. perl should also check whether `cmd`
reports an error.

No doubt if I used the list form of open() everything would work, as
there's no shell interpretation required then, but I can't because that
doesn't support pipe-open on Windows perl < 5.22.

Is this a bug, or is it documented somewhere and I've just not found it?
(In which case is it a documentation bug? `perldoc -f open` should, I
think, contain at least a hint :-)

-- 
David Cantrell | Bourgeois reactionary pig

    Support terrierism! Adopt a dog today!

Thread Next


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