chiark / gitweb /
Test suite: build-modes tests: Do extra clean mode tests with build-source
[dgit.git] / Debian / Dgit.pm
index d66b712bc86af9ba104a88cc0bbac06e375d2370..a453f352718b33a5567e040cdd9302973c40b279 100644 (file)
@@ -26,7 +26,7 @@ BEGIN {
                       initdebug enabledebug enabledebuglevel
                       printdebug debugcmd
                       $debugprefix *debuglevel *DEBUG
-                      shellquote printcmd);
+                      shellquote printcmd messagequote);
     # implicitly uses $main::us
     %EXPORT_TAGS = ( policyflags => [qw(NOFFCHECK FRESHREPO)] );
     @EXPORT_OK   = @{ $EXPORT_TAGS{policyflags} };
@@ -81,12 +81,22 @@ sub printdebug {
     print DEBUG $debugprefix, @_ or die $! if $debuglevel>0;
 }
 
+sub messagequote ($) {
+    local ($_) = @_;
+    s{\\}{\\\\}g;
+    s{\n}{\\n}g;
+    s{\x08}{\\b}g;
+    s{\t}{\\t}g;
+    s{[\000-\037\177]}{ sprintf "\\x%02x", ord $& }ge;
+    $_;
+}
+
 sub shellquote {
     my @out;
     local $_;
     foreach my $a (@_) {
        $_ = $a;
-       if (!length || m{[^-=_./0-9a-z]}i) {
+       if (!length || m{[^-=_./:0-9a-z]}i) {
            s{['\\]}{'\\$&'}g;
            push @out, "'$_'";
        } else {