From: Eric Wong Date: Thu, 6 Jun 2024 07:44:12 +0000 (+0000) Subject: treewide: use \*STD(IN|OUT|ERR) consistently X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d3a40880ef8252c3e9aa8765b14ea38b91901aa;p=thirdparty%2Fpublic-inbox.git treewide: use \*STD(IN|OUT|ERR) consistently Referencing the {IO} slot may not always be populated or work (e.g. with `-t' filetest) if there's no IO handle. Using merely using `\*' is shorter than typing out `{GLOB}', so just use the shortest form consistently. This may fix occasional and difficult-to-reproduce failures from redirecting STDERR in t/imap_searchqp.t --- diff --git a/lib/PublicInbox/Admin.pm b/lib/PublicInbox/Admin.pm index a1b1fc079..a2045b37d 100644 --- a/lib/PublicInbox/Admin.pm +++ b/lib/PublicInbox/Admin.pm @@ -317,7 +317,7 @@ sub progress_prepare ($;$) { $opt->{1} = $null; # suitable for spawn() redirect } else { $opt->{verbose} ||= 1; - $dst //= *STDERR{GLOB}; + $dst //= \*STDERR; $opt->{-progress} = sub { print $dst '# ', @_ }; } } diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm index 7162732ec..b7728bd25 100644 --- a/lib/PublicInbox/HTTP.pm +++ b/lib/PublicInbox/HTTP.pm @@ -47,7 +47,7 @@ open(my $null_io, '<', '/dev/null') or die "open /dev/null: $!"; { my @n = stat($null_io) or die "stat(/dev/null): $!"; my @i = stat(STDIN) or die "stat(STDIN): $!"; - $null_io = *STDIN{IO} if "@n[0, 1]" eq "@i[0, 1]"; + $null_io = \*STDIN if "@n[0, 1]" eq "@i[0, 1]"; } my $http_date; diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index e9a0de6c8..309d290da 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -506,12 +506,12 @@ sub x_it ($$) { sub err ($;@) { my $self = shift; - my $err = $self->{2} // ($self->{pgr} // [])->[2] // *STDERR{GLOB}; + my $err = $self->{2} // ($self->{pgr} // [])->[2] // \*STDERR; my @eor = (substr($_[-1]//'', -1, 1) eq "\n" ? () : ("\n")); print $err @_, @eor and return; my $old_err = delete $self->{2}; $old_err->close if $! == EPIPE && $old_err; - $err = $self->{2} = ($self->{pgr} // [])->[2] // *STDERR{GLOB}; + $err = $self->{2} = ($self->{pgr} // [])->[2] // \*STDERR; print $err @_, @eor or print STDERR @_, @eor; } @@ -1556,7 +1556,7 @@ sub sto_barrier_request { eval { $lei->{sto}->wq_do('schedule_commit', $n) }; } else { my $s = ($wq ? $wq->{lei_sock} : undef) // $lei->{sock}; - my $errfh = $lei->{2} // *STDERR{GLOB}; + my $errfh = $lei->{2} // \*STDERR; my @io = $s ? ($errfh, $s) : ($errfh); eval { $lei->{sto}->wq_io_do('barrier', \@io, 1) }; } diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm index 3a67ab541..a01949a37 100644 --- a/lib/PublicInbox/TestCommon.pm +++ b/lib/PublicInbox/TestCommon.pm @@ -281,8 +281,7 @@ sub key2script ($) { 'blib/script/'.$key; } -my @io_mode = ([ *STDIN{IO}, '+<&' ], [ *STDOUT{IO}, '+>&' ], - [ *STDERR{IO}, '+>&' ]); +my @io_mode = ([ \*STDIN, '+<&' ], [ \*STDOUT, '+>&' ], [ \*STDERR, '+>&' ]); sub _prepare_redirects ($) { my ($fhref) = @_; diff --git a/lib/PublicInbox/WwwCoderepo.pm b/lib/PublicInbox/WwwCoderepo.pm index 8587f5302..8d8252849 100644 --- a/lib/PublicInbox/WwwCoderepo.pm +++ b/lib/PublicInbox/WwwCoderepo.pm @@ -87,7 +87,7 @@ sub new { my @s = stat(STDIN) or die "stat(STDIN): $!"; if ("@l[0, 1]" eq "@s[0, 1]") { my $f = fcntl(STDIN, F_GETFL, 0); - $self->{log_fh} = *STDIN{IO} if $f & O_RDWR; + $self->{log_fh} = \*STDIN if $f & O_RDWR; } $self; } diff --git a/script/lei b/script/lei index 087afc330..a5aef9568 100755 --- a/script/lei +++ b/script/lei @@ -37,7 +37,7 @@ my $exec_cmd = sub { my ($fds, $argc, @argv) = @_; my $parent = $$; require POSIX; - my @old = (*STDIN{IO}, *STDOUT{IO}, *STDERR{IO}); + my @old = (\*STDIN, \*STDOUT, \*STDERR); my @rdr; for my $fd (@$fds) { open(my $newfh, '+<&=', $fd) or die "open +<&=$fd: $!"; diff --git a/script/public-inbox-clone b/script/public-inbox-clone index c3e644858..5ecf11ae7 100755 --- a/script/public-inbox-clone +++ b/script/public-inbox-clone @@ -54,7 +54,7 @@ require PublicInbox::LeiMirror; $url = PublicInbox::LeiExternal::ext_canonicalize($url); my $lei = bless { env => \%ENV, opt => $opt, cmd => 'public-inbox-clone', - 0 => *STDIN{GLOB}, 2 => *STDERR{GLOB}, + 0 => \*STDIN, 2 => \*STDERR, }, 'PublicInbox::LEI'; open $lei->{1}, '+<&=', 1 or die "dup: $!"; open $lei->{3}, '.' or die "open . $!"; diff --git a/script/public-inbox-fetch b/script/public-inbox-fetch index 6fd15328a..1ae311714 100755 --- a/script/public-inbox-fetch +++ b/script/public-inbox-fetch @@ -33,7 +33,7 @@ $SIG{PIPE} = 'IGNORE'; my $lei = bless { env => \%ENV, opt => $opt, cmd => 'public-inbox-fetch', - 0 => *STDIN{GLOB}, 1 => *STDOUT{GLOB}, 2 => *STDERR{GLOB}, + 0 => \*STDIN, 1 => \*STDOUT, 2 => \*STDERR, }, 'PublicInbox::LEI'; PublicInbox::Fetch->do_fetch($lei, '.'); exit(($lei->{child_error} // 0) >> 8);