summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2013-09-26 22:37:37 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2013-09-26 22:37:37 +0100
commit30ecd0c98b1076d3245f225f331349c5901b890e (patch)
tree143ad5d6aba0101e856ea289d024775b71d782b8
parent91f37f511e100757d329e0f0e9cfd54c749708c3 (diff)
wip changes for remote push - break out shellquote, nfc
-rwxr-xr-xdgit18
1 files changed, 12 insertions, 6 deletions
diff --git a/dgit b/dgit
index c24a950..1968d8c 100755
--- 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 $!;
}