From 3ed89ae9324026660dfefb5e482e91b8acc5262d Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Sat, 9 Jan 2016 01:38:30 +0000 Subject: 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. --- src/wc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/wc.c') 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'); } -- cgit v1.2.3-54-g00ecf