195
my %cvsstat;
196
if (@canstatusfiles) {
197
if ($opt_u) {
198
- my @updated = safe_pipe_capture(@cvs, 'update', @canstatusfiles);
198
+ my @updated = xargs_safe_pipe_capture([@cvs, 'update'], @canstatusfiles);
199
print @updated;
200
}
201
my @cvsoutput;
202
- @cvsoutput= safe_pipe_capture(@cvs, 'status', @canstatusfiles);
202
+ @cvsoutput = xargs_safe_pipe_capture([@cvs, 'status'], @canstatusfiles);
203
my $matchcount = 0;
204
foreach my $l (@cvsoutput) {
205
chomp $l;
295
296
if ($opt_c) {
297
print "Autocommit\n $cmd\n";
298
- print safe_pipe_capture(@cvs, 'commit', '-F', '.msg', @files);
298
+ print xargs_safe_pipe_capture([@cvs, 'commit', '-F', '.msg'], @files);
299
if ($?) {
300
die "Exiting: The commit did not succeed";
301
}
335
return wantarray ? @output : join('',@output);
336
}
337
338
-sub safe_pipe_capture_blob {
339
- my $output;
340
- if (my $pid = open my $child, '-|') {
341
- local $/;
342
- undef $/;
343
- $output = (<$child>);
344
- close $child or die join(' ',@_).": $! $?";
345
- } else {
346
- exec(@_) or die "$! $?"; # exec() can fail the executable can't be found
347
- }
348
- return $output;
338
+sub xargs_safe_pipe_capture {
339
+ my $MAX_ARG_LENGTH = 65536;
340
+ my $cmd = shift;
341
+ my @output;
342
+ my $output;
343
+ while(@_) {
344
+ my @args;
345
+ my $length = 0;
346
+ while(@_ && $length < $MAX_ARG_LENGTH) {
347
+ push @args, shift;
348
+ $length += length($args[$#args]);
349
+ }
350
+ if (wantarray) {
351
+ push @output, safe_pipe_capture(@$cmd, @args);
352
+ }
353
+ else {
354
+ $output .= safe_pipe_capture(@$cmd, @args);
355
+ }
356
+ }
357
+ return wantarray ? @output : $output;
358
}