about summary refs log tree commit homepage
path: root/lib/PublicInbox/Config.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-10-27 22:21:13 +0000
committerEric Wong <e@80x24.org>2023-10-28 09:08:18 +0000
commit73830410e4336b779c820e90a8604e9e74f38b90 (patch)
tree92962cefd15d77edb12c57d08cc89b0d37110d67 /lib/PublicInbox/Config.pm
parentef5bd67cbcdcd8cba2cb8b3718ea90afda6b7ebe (diff)
downloadpublic-inbox-73830410e4336b779c820e90a8604e9e74f38b90.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/Config.pm')
-rw-r--r--lib/PublicInbox/Config.pm14
1 files changed, 6 insertions, 8 deletions
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;
         }