From 73830410e4336b779c820e90a8604e9e74f38b90 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 27 Oct 2023 22:21:13 +0000 Subject: treewide: use run_qx where appropriate This saves us some code, and is a small step towards getting ProcessIO working with stat, fcntl and other perlops that don't work with tied handles. --- lib/PublicInbox/Config.pm | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'lib/PublicInbox/Config.pm') diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index d156b2d3..0a572103 100644 --- a/lib/PublicInbox/Config.pm +++ b/lib/PublicInbox/Config.pm @@ -13,7 +13,7 @@ use v5.10.1; use parent qw(Exporter); our @EXPORT_OK = qw(glob2re rel2abs_collapsed); use PublicInbox::Inbox; -use PublicInbox::Spawn qw(popen_rd); +use PublicInbox::Spawn qw(popen_rd run_qx); our $LD_PRELOAD = $ENV{LD_PRELOAD}; # only valid at startup our $DEDUPE; # set to {} to dedupe or clear cache @@ -576,23 +576,21 @@ sub urlmatch { my (%env, %opt); my $cmd = $self->config_cmd(\%env, \%opt); push @$cmd, @bool, qw(--includes -z --get-urlmatch), $key, $url; - my $fh = popen_rd($cmd, \%env, \%opt); - local $/ = "\0"; - my $val = <$fh>; - if (!close($fh)) { + my $val = run_qx($cmd, \%env, \%opt); + if ($?) { undef $val; if (@bool && ($? >> 8) == 128) { # not boolean } elsif (($? >> 8) != 1) { $urlmatch_broken = 1; } elsif ($try_git) { # n.b. this takes cwd into account - $fh = popen_rd([qw(git config), @bool, + $val = run_qx([qw(git config), @bool, qw(-z --get-urlmatch), $key, $url]); - $val = <$fh>; - close($fh) or undef($val); + undef $val if $?; } } $? = 0; # don't influence lei exit status if (defined($val)) { + local $/ = "\0"; chomp $val; $val = git_bool($val) if @bool; } -- cgit v1.2.3-24-ge0c7