From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id B4F631F565 for ; Sun, 24 Sep 2023 05:42:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1695534134; bh=er3LQ4D5zXbJ71APxzpPv7ZEyGXBfBcyNGkMMgcJFNk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kGD9uwb4FtxrJJBcXGX5uxhjd8CuGqAK9lPxSQieJK1UbszBXuCYBSWi9PQwMuYnX Up7ZYTYBOBWqNhhJw/SxAcdR1qTWjaMsvuFPMaY4vElhx99iIMxdLUD8NNiHMjdY8Z LLebxNqtjn5wUFekoS6JOx45svkIEyhtCpo40tU8= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/6] lei view_text: used tied ProcessPipe for `git config' Date: Sun, 24 Sep 2023 05:42:10 +0000 Message-ID: <20230924054214.3539091-3-e@80x24.org> In-Reply-To: <20230924054214.3539091-1-e@80x24.org> References: <20230924054214.3539091-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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(-) 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;