From b93890e268e375a980a0b4b3cfc30cf6192747c1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 24 Sep 2023 05:42:10 +0000 Subject: lei view_text: used tied ProcessPipe for `git config' The code exists and is loaded anyways, so we might as well save an explicit call to waitpid. Noticed while checking over our uses of `git config' --- lib/PublicInbox/LeiViewText.pm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lib/PublicInbox') diff --git a/lib/PublicInbox/LeiViewText.pm b/lib/PublicInbox/LeiViewText.pm index 53555467..70441867 100644 --- a/lib/PublicInbox/LeiViewText.pm +++ b/lib/PublicInbox/LeiViewText.pm @@ -72,12 +72,11 @@ sub new { my $self = bless { %{$lei->{opt}}, -colored => \&uncolored }, $cls; $self->{-quote_reply} = 1 if $fmt eq 'reply'; return $self unless $self->{color} //= -t $lei->{1}; - my $cmd = [ qw(git config -z --includes -l) ]; - my ($r, $pid) = popen_rd($cmd, undef, { 2 => $lei->{2} }); + my @cmd = qw(git config -z --includes -l); # reuse normal git config + my $r = popen_rd(\@cmd, undef, { 2 => $lei->{2} }); my $cfg = PublicInbox::Config::config_fh_parse($r, "\0", "\n"); - waitpid($pid, 0); - if ($?) { - warn "# git-config failed, no color (non-fatal)\n"; + if (!close($r)) { + warn "# @cmd failed, no color (non-fatal \$?=$?)\n"; return $self; } $self->{-colored} = \&my_colored; -- cgit v1.2.3-24-ge0c7