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

pipe-open on Windows tells porkies about failures

Thread Next
David Cantrell
July 8, 2021 10:08
pipe-open on Windows tells porkies about failures
Message ID:
I got an interesting CPAN-testers failure recently:

for this code:

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:

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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About