X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=dgit;h=1968d8c1b7895f0dcedd17d47532acb417d3bf7c;hb=30ecd0c98b1076d3245f225f331349c5901b890e;hp=c24a95034332ff32ec285f82418ace95aa8d4b93;hpb=91f37f511e100757d329e0f0e9cfd54c749708c3;p=dgit.git 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 $!; }