From 30ecd0c98b1076d3245f225f331349c5901b890e Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 26 Sep 2013 22:37:37 +0100 Subject: [PATCH] wip changes for remote push - break out shellquote, nfc --- dgit | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/dgit b/dgit index c24a9503..1968d8c1 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 $!; } -- 2.30.2