Eric Wong <e...@80x24.org> wrote: > +++ b/t/lei-store-fail.t > + my $cmd = [ qw(lei import -q -F mboxrd) ]; > + my $tp = start_script($cmd, undef, $opt);
Of course the lack of `-' or `--stdin' only worked on Linux and NetBSD, but not other BSDs. -------8<------ Subject: [PATCH] lei: fix implicit stdin support for pipes st_mode permission bits can't be used to determine if a file or pipe we have on stdin readable or not. Writable regular files can be opened O_RDONLY, and permissions bits for pipes are inconsistent across platforms. On FreeBSD, OpenBSD, and Dragonfly, only the S_IFIFO bit is set in st_mode with none of the permission bits are set. Linux and NetBSD have both the read and write permission bits set for both ends of a the pipe, so they're just as inaccurate but allowed the feature to work before this change. For now, we'll just assume our users know that stdin is intended for input and consider any pipe or regular file to be readable. If we were to be pedantic, we'd check O_RDONLY or O_RDWR description flags via the F_GETFL fcntl(2) op to determine if a pipe or socket is readable. However, I don't think it's worth the code to do so. --- lib/PublicInbox/LEI.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index f00b2465..1ba2c2a1 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -747,7 +747,7 @@ sub optparse ($$$) { # w/o args means stdin if ($sw eq 'stdin' && !@$argv && (-p $self->{0} || - -f _) && -r _) { + -f _)) { $OPT->{stdin} //= 1; } $ok = defined($OPT->{$sw}) and last;