diff options
author | Eric Wong <e@80x24.org> | 2014-04-30 01:03:30 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2014-04-30 01:07:35 +0000 |
commit | 6cd8fe54810e6f6659894df66f2a11ec96bb5114 (patch) | |
tree | 3b9937c4387c8894099aa3ab3a919e1cf0dcafe3 /public-inbox.cgi | |
parent | 05d1dac95a93902b5f2877d01c77f02c6455eb85 (diff) | |
download | public-inbox-6cd8fe54810e6f6659894df66f2a11ec96bb5114.tar.gz |
We may not have PATH available on some servers (e.g. webrick) and must rely on the hardcoded system PATH. My installation of IPC::Run does not seem to work without PATH set in the env, however normal Perl "open" calls work fine.
Diffstat (limited to 'public-inbox.cgi')
-rwxr-xr-x | public-inbox.cgi | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/public-inbox.cgi b/public-inbox.cgi index b63223f5..da87d2c3 100755 --- a/public-inbox.cgi +++ b/public-inbox.cgi @@ -147,13 +147,21 @@ sub mid2blob { my $hex = Digest::SHA::sha1_hex($ctx->{mid}); $hex =~ /\A([a-f0-9]{2})([a-f0-9]{38})\z/i or die "BUG: not a SHA-1 hex: $hex"; - require IPC::Run; - my ($in, $blob, $err); - open my $null, '+<', '/dev/null' or die "open: $!\n"; - IPC::Run::run(['git', "--git-dir=$ctx->{git_dir}", - qw(cat-file blob), "HEAD:$1/$2"], - $null, \$blob, $null); - $? == 0 ? \$blob : undef; + + my @cmd = ('git', "--git-dir=$ctx->{git_dir}", + qw(cat-file blob), "HEAD:$1/$2"); + my $cmd = join(' ', @cmd); + my $pid = open my $fh, '-|'; + defined $pid or die "fork failed: $!\n"; + if ($pid == 0) { + open STDERR, '>', '/dev/null'; # ignore errors + exec @cmd; + exit 1; + } else { + my $blob = eval { local $/; <$fh> }; + close $fh; + $? == 0 ? \$blob : undef; + } } # /$LISTNAME/m/$MESSAGE_ID.txt -> raw original |