From 4bf3fe6a811c6e024af3580f2da15c234fb53011 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 15 Nov 2023 04:32:39 +0000 Subject: treewide: more autodie safety fixes for older Perl Avoid mixing autodie use in different scopes since it's likely to cause problems like it did in Gcf2. While none of these fix known problems with test cases, it's likely worthwhile to avoid it anyways to avoid future surprises. For Process::IO, we'll add some additional tests in t/io.t to ensure we don't get unintended exceptions for try_cat. --- lib/PublicInbox/LEI.pm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/PublicInbox/LEI.pm') diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 69065ce7..460aed40 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -9,7 +9,7 @@ package PublicInbox::LEI; use v5.12; use parent qw(PublicInbox::DS PublicInbox::LeiExternal PublicInbox::LeiQuery); -use autodie qw(bind chdir fork open socket socketpair syswrite unlink); +use autodie qw(bind chdir fork open pipe socket socketpair syswrite unlink); use Getopt::Long (); use Socket qw(AF_UNIX SOCK_SEQPACKET pack_sockaddr_un); use Errno qw(EPIPE EAGAIN ECONNREFUSED ENOENT ECONNRESET); @@ -1099,8 +1099,8 @@ sub start_pager { $new_env->{LESS} //= 'FRX'; $new_env->{LV} //= '-c'; $new_env->{MORE} = $new_env->{LESS} if $^O eq 'freebsd'; - pipe(my ($r, $wpager)) or return warn "pipe: $!"; - my $rdr = { 0 => $r, 1 => $self->{1}, 2 => $self->{2} }; + my $rdr = { 1 => $self->{1}, 2 => $self->{2} }; + CORE::pipe($rdr->{0}, my $wpager) or return warn "pipe: $!"; my $pgr = [ undef, @$rdr{1, 2} ]; my $env = $self->{env}; if ($self->{sock}) { # lei(1) process runs it @@ -1580,7 +1580,6 @@ sub slurp_stdin { my $in = $lei->{0}; if (-t $in) { # run cat via script/lei and read from it $in = undef; - use autodie qw(pipe); pipe($in, my $wr); say { $lei->{2} } '# enter query, Ctrl-D when done'; send_exec_cmd($lei, [ $lei->{0}, $wr ], ['cat'], {}); -- cgit v1.2.3-24-ge0c7