From: Ian Jackson Date: Thu, 26 Sep 2013 21:37:37 +0000 (+0100) Subject: wip changes for remote push - break out shellquote, nfc X-Git-Tag: debian/0.16_experimental2^2~21 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=commitdiff_plain;h=30ecd0c98b1076d3245f225f331349c5901b890e wip changes for remote push - break out shellquote, nfc --- 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 $!; }