-# Copyright (C) 2014, Eric Wong <normalperson@yhbt.net> and all contributors
+# Copyright (C) 2014-2015 all contributors <meta@public-inbox.org>
# License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
package PublicInbox::Config;
use strict;
use warnings;
use File::Path::Expand qw/expand_filename/;
-use IPC::Run;
# returns key-value pairs of config directives in a hash
# if keys may be multi-value, the value is an array ref containing all values
my ($in, $out);
$file = default_file() unless defined($file);
- IPC::Run::run([qw/git config --file/, $file, '-l'], \$in, \$out);
- $? == 0 or die "git config --file $file -l failed: $?\n";
+ my @cmd = (qw/git config/, "--file=$file", '-l');
+ my $cmd = join(' ', @cmd);
+ my $pid = open(my $fh, '-|', @cmd);
+ defined $pid or die "$cmd failed: $!\n";
my %rv;
- foreach my $line (split(/\n/, $out)) {
+ foreach my $line (<$fh>) {
+ chomp $line;
my ($k, $v) = split(/=/, $line, 2);
my $cur = $rv{$k};
$rv{$k} = $v;
}
}
+ close $fh or die "failed to close ($cmd) pipe: $!\n";
+ $? and warn "$$ $cmd exited with: ($pid) $?\n";
bless \%rv, $class;
}