mirror of
https://github.com/git/git
synced 2024-10-03 23:29:36 +00:00
d13a73e383
The following commit will make use of a Getopt::Long feature which is
only present in Perl >= 5.8.1. Document that as the minimum version we
support.
Many of our Perl scripts will continue to run with 5.8.0 but this change
allows us to adjust them as needed without breaking any promises to our
users.
The Perl requirement was last changed in d48b284183
(perl: bump the
required Perl version to 5.8 from 5.6.[21], 2010-09-24). At that time,
5.8.0 was 8 years old. It is now over 21 years old.
Signed-off-by: Todd Zullinger <tmz@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
37 lines
864 B
Perl
37 lines
864 B
Perl
use 5.008001;
|
|
use strict;
|
|
use warnings;
|
|
|
|
my $body_filename = $ARGV[0];
|
|
my @command = @ARGV[1 .. $#ARGV];
|
|
|
|
# read data
|
|
my $body_size = -s $body_filename;
|
|
$ENV{"CONTENT_LENGTH"} = $body_size;
|
|
open(my $body_fh, "<", $body_filename) or die "Cannot open $body_filename: $!";
|
|
my $body_data;
|
|
defined read($body_fh, $body_data, $body_size) or die "Cannot read $body_filename: $!";
|
|
close($body_fh);
|
|
|
|
# write data
|
|
my $pid = open(my $out, "|-", @command);
|
|
{
|
|
# disable buffering at $out
|
|
my $old_selected = select;
|
|
select $out;
|
|
$| = 1;
|
|
select $old_selected;
|
|
}
|
|
print $out $body_data or die "Cannot write data: $!";
|
|
|
|
$SIG{ALRM} = sub {
|
|
kill 'KILL', $pid;
|
|
die "Command did not exit after reading whole body";
|
|
};
|
|
alarm 60;
|
|
|
|
my $ret = waitpid($pid, 0);
|
|
if ($ret != $pid) {
|
|
die "confusing return from waitpid: $ret";
|
|
}
|