chiark / gitweb /
wip changes for remote push - break out shellquote, nfc
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 26 Sep 2013 21:37:37 +0000 (22:37 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 26 Sep 2013 21:37:37 +0000 (22:37 +0100)
dgit

diff --git a/dgit b/dgit
index c24a95034332ff32ec285f82418ace95aa8d4b93..1968d8c1b7895f0dcedd17d47532acb417d3bf7c 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -183,19 +183,25 @@ sub url_get {
 
 our ($dscdata,$dscurl,$dsc,$skew_warning_vsn);
 
-sub printcmd {
-    my $fh = shift @_;
-    my $intro = shift @_;
-    print $fh $intro or die $!;
+sub shellquote {
+    my @out;
     local $_;
     foreach my $a (@_) {
        $_ = $a;
        if (s{['\\]}{\\$&}g || m{\s} || m{[^-_./0-9a-z]}i) {
-           print $fh " '$_'" or die $!;
+           push @out, "'$_'";
        } else {
-           print $fh " $_" or die $!;
+           push @out, $_;
        }
     }
+    return join '', @out;
+}
+
+sub printcmd {
+    my $fh = shift @_;
+    my $intro = shift @_;
+    print $fh $intro or die $!;
+    print $fh shellquote @_ or die $!;
     print $fh "\n" or die $!;
 }