summaryrefslogtreecommitdiff
path: root/src/wc.c
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2016-01-09 01:38:30 +0000
committerPádraig Brady <P@draigBrady.com>2016-01-13 11:11:36 +0000
commit3ed89ae9324026660dfefb5e482e91b8acc5262d (patch)
tree77025a5cb78df0fd5ffad2929a3023181b37c4a1 /src/wc.c
parent672663e1b0afd68a10d991527fd5021c40c99acc (diff)
downloadcoreutils-3ed89ae9324026660dfefb5e482e91b8acc5262d.tar.xz
wc: avoid ambiguous output with '\n' in file names
* src/wc.c (write_counts): Shell escape the file name if it contains '\n' so only a single line per file is output. * tests/misc/wc-files0.sh: Add a test case. * NEWS: Mention the improvement.
Diffstat (limited to 'src/wc.c')
-rw-r--r--src/wc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/wc.c b/src/wc.c
index c2a9c3fbe..94cbaff9a 100644
--- a/src/wc.c
+++ b/src/wc.c
@@ -182,7 +182,7 @@ write_counts (uintmax_t lines,
printf (format_int, number_width, umaxtostr (linelength, buf));
}
if (file)
- printf (" %s", file);
+ printf (" %s", strchr (file, '\n') ? quotef (file) : file);
putchar ('\n');
}