From: Eric Wong Date: Thu, 24 Nov 2005 07:47:39 +0000 (-0800) Subject: archimport: first, make sure it still compiles X-Git-Tag: v0.99.9m^2~15 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;ds=sidebyside;h=2777ef76be7174f698b3f53cc4ff38b4118de320;p=git.git archimport: first, make sure it still compiles (ML: And introduce safe_pipe_capture()) Signed-off-by: Eric Wong Signed-off-by: Martin Langhoff --- diff --git a/git-archimport.perl b/git-archimport.perl index c3bed080..b5f8a2c6 100755 --- a/git-archimport.perl +++ b/git-archimport.perl @@ -99,6 +99,7 @@ my %psets = (); # the collection, by name my %rptags = (); # my reverse private tags # to map a SHA1 to a commitid +my $TLA = $ENV{'ARCH_CLIENT'} || 'tla'; foreach my $root (@arch_roots) { my ($arepo, $abranch) = split(m!/!, $root); @@ -850,3 +851,18 @@ sub commitid2pset { || (print Dumper(sort keys %psets)) && die "Cannot find patchset for $name"; return $ps; } + +# an alterative to `command` that allows input to be passed as an array +# to work around shell problems with weird characters in arguments +sub safe_pipe_capture { + my @output; + if (my $pid = open my $child, '-|') { + @output = (<$child>); + close $child or die join(' ',@_).": $! $?"; + } else { + exec(@_) or die $?; # exec() can fail the executable can't be found + } + return wantarray ? @output : join('',@output); +} + +