develooper Front page | perl.perl5.porters | Postings from November 2022 - Handle FIFOs / Named Pipes (PR #20472)

Thread Next
Dabrien 'Dabe' Murphy
November 4, 2022 22:04
Subject: - Handle FIFOs / Named Pipes (PR #20472)
Message ID:
On 11/1/22 8:11 PM, James E Keenan <> wrote:
> Whether we want FindBin to handle FIFOs and named pipes is something 
> that really ought to be discussed first on the Perl5-Porters mailing list.

Gladly!  :-D

So, this dies:

bash%  perl -MFindBin <(echo 'print "$FindBin::Bin\n"')
Cannot find current script '/dev/fd/63' at line 167.
BEGIN failed--compilation aborted at line 167.

... and rather than expecting downstream modules to wrap their imports 
in an `eval`:

BEGIN { eval "use FindBin ()" }
eval "FindBin::again()";

... this trivial change fixes the problem, and doesn't seem to introduce 
any apparent[*] regressions:

--- a/dist/FindBin/lib/
+++ b/dist/FindBin/lib/
@@ -114,2 +114,2 @@ sub init
- if($0 eq '-e' || $0 eq '-')
+ if($0 eq '-e' || $0 eq '-' || -p $0)


I feel like the omission of `-p` was more of an oversight, rather than 
being expressly forbidden; it skews heavily toward the "Make The Hard 
Things Possible" end of the spectrum, and probably just nobody thought 
to try it before.

IMHO, if `FindBin` can handle an *unnamed* pipe — STDIN — then it should 
treat a **NAMED** pipe/FIFO the same way, i.e., return the current 

> Having some of the regression tests depend on using bash as our shell 
> will not fly. Perl builds on many operating systems, not all of which 
> support bash and we use quite a few more shells than just bash

Oh, I'll absolutely be the very first to admit that shelling out to 
`bash` was chock full of Code Smell; that's why I put a big `skip_all()` 
at the top, for systems/environments where bash isn't available...

But for the vast percentage of systems where it **DOES** exist, it also 
seemed like the "Simplest Thing That Could Possibly Work",as well as 
being the most common situation to bite people in the wild...  My guess 
is that anything "smarter" — e.g., calling `POSIX::mkfifo(mktemp, 0600)` 
and then `dup(2)`-ing that to `t/ => runperl()`'s `\*STDIN`, or 
some such — would only introduce MORE portability headaches.  «shrug»

Anyway, I'm more than happy to jettison the whole `exec bash` nonsense!  
I just figured having at least *ONE* test for the Happy Path would be 
better than not providing any new `t/` tests at all...

Cheers!  :-D

:- Dabe

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About