archimport: first, make sure it still compiles
(ML: And introduce safe_pipe_capture()) Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Martin Langhoff <martin@catalyst.net.nz>
Eric Wong committed
Nov 23, 2005 at 23:47 UTC
2777ef76be7174f698b3f53cc4ff38b4118de320
1 file changed
+16
git-archimport.perl
+16
@@ -99,6 +99,7 @@ my %psets = (); # the collection, by name
99
100
my %rptags = (); # my reverse private tags
101
# to map a SHA1 to a commitid
102
+my $TLA = $ENV{'ARCH_CLIENT'} || 'tla';
103
104
foreach my $root (@arch_roots) {
105
my ($arepo, $abranch) = split(m!/!, $root);
@@ -850,3 +851,18 @@ sub commitid2pset {
851
|| (print Dumper(sort keys %psets)) && die "Cannot find patchset for $name";
852
return $ps;
853
}
854
+
855
+# an alterative to `command` that allows input to be passed as an array
856
+# to work around shell problems with weird characters in arguments
857
+sub safe_pipe_capture {
858
+ my @output;
859
+ if (my $pid = open my $child, '-|') {
860
+ @output = (<$child>);
861
+ close $child or die join(' ',@_).": $! $?";
862
+ } else {
863
+ exec(@_) or die $?; # exec() can fail the executable can't be found
864
+ }
865
+ return wantarray ? @output : join('',@output);
866
+}
867
+
868
+