]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
paste: avoid confusing backslash quoting in diagnostic
authorPádraig Brady <P@draigBrady.com>
Wed, 4 Nov 2015 01:14:33 +0000 (01:14 +0000)
committerPádraig Brady <P@draigBrady.com>
Wed, 4 Nov 2015 23:30:15 +0000 (23:30 +0000)
* src/paste.c (main): Setting the quoting style to "escape"
went against the intent of the comment about presenting
doubled backslashes to the user.  Instead use "c-maybe"
which is the only mode which avoids doubled backslashes,
and provides protection against arbitrary control characters.
* tests/misc/paste.pl: Adjust accordingly.

src/paste.c
tests/misc/paste.pl

index 5781ccd3e8a42281527865af3f355a1516661479..761ae8d94071488ece86fef3eb5983ea9cb220c8 100644 (file)
@@ -500,9 +500,9 @@ main (int argc, char **argv)
 
   if (collapse_escapes (delim_arg))
     {
-      /* Don't use the default quoting style, because that would double the
+      /* Don't use the quote() quoting style, because that would double the
          number of displayed backslashes, making the diagnostic look bogus.  */
-      set_quoting_style (NULL, escape_quoting_style);
+      set_quoting_style (NULL, c_maybe_quoting_style);
       error (EXIT_FAILURE, 0,
              _("delimiter list ends with an unescaped backslash: %s"),
              quotearg_colon (delim_arg));
index 8d957f4698da615123362fe7592e8b8aa75d57f3..962f84a42a33279b9b481b1b28c2542b08d0b26d 100755 (executable)
@@ -44,9 +44,8 @@ my @Tests =
    # Specifying a delimiter with a trailing backslash would overrun a
    # malloc'd buffer.
    ['delim-bs1', q!-d'\'!, {IN=>{'a'x50=>''}}, {EXIT => 1},
-    # We print a single backslash into the expected output, so need four
-    # (two, each escaped) here.
-    {ERR => $msg . q!\\\\! . "\n"} ],
+    # We print a single backslash into the expected output
+    {ERR => $msg . q!\\! . "\n"} ],
 
    # Prior to coreutils-5.1.2, this sort of abuse would make paste
    # scribble on command-line arguments.  With paste from coreutils-5.1.0,
@@ -55,7 +54,7 @@ my @Tests =
    # $ paste -d\\ '123\b\b\b.....@' 2>&1 |cat -A
    # paste: 23^H^H^H.....@...@: No such file or directory$
    ['delim-bs2', q!-d'\'!, {IN=>{'123\b\b\b.....@'=>''}}, {EXIT => 1},
-    {ERR => $msg . q!\\\\! . "\n"} ],
+    {ERR => $msg . q!\\! . "\n"} ],
   );
 
 my $save_temps = $ENV{DEBUG};