summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-11-04 01:14:33 +0000
committerPádraig Brady <P@draigBrady.com>2015-11-04 23:30:15 +0000
commitc3763e5219979a714d380304b4847c9b1671241a (patch)
treec03037a34bc7d825889134b3ad53cededd1bab16
parent109b9220cead6e979d22d16327c4d9f8350431cc (diff)
downloadcoreutils-c3763e5219979a714d380304b4847c9b1671241a.tar.xz
paste: avoid confusing backslash quoting in diagnostic
* 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.
-rw-r--r--src/paste.c4
-rwxr-xr-xtests/misc/paste.pl7
2 files changed, 5 insertions, 6 deletions
diff --git a/src/paste.c b/src/paste.c
index 5781ccd3e..761ae8d94 100644
--- a/src/paste.c
+++ b/src/paste.c
@@ -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));
diff --git a/tests/misc/paste.pl b/tests/misc/paste.pl
index 8d957f469..962f84a42 100755
--- a/tests/misc/paste.pl
+++ b/tests/misc/paste.pl
@@ -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};