summaryrefslogtreecommitdiff
path: root/src/cat.c
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-10-27 13:13:59 +0000
committerPádraig Brady <P@draigBrady.com>2015-10-27 17:24:54 +0000
commit6796698c9945d87236ffcc939137d0919ef04931 (patch)
treedd843e7808186887c2959451e34fdd7f42783359 /src/cat.c
parent106d4bf159a97b573d6479473fa38216fb8bfada (diff)
downloadcoreutils-6796698c9945d87236ffcc939137d0919ef04931.tar.xz
all: quote string arguments in error messages
These strings are often file names or other user specified parameters, which can give confusing errors in the presence of unexpected characters for example. * cfg.mk (sc_error_quotes): A new syntax check rule. * src/*.c: Wrap error() string arguments with quote(). * tests/: Adjust accordingly. * NEWS: Mention the improvement.
Diffstat (limited to 'src/cat.c')
-rw-r--r--src/cat.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/cat.c b/src/cat.c
index 948f1341b..01a66c0a1 100644
--- a/src/cat.c
+++ b/src/cat.c
@@ -169,7 +169,7 @@ simple_cat (
n_read = safe_read (input_desc, buf, bufsize);
if (n_read == SAFE_READ_ERROR)
{
- error (0, errno, "%s", infile);
+ error (0, errno, "%s", quote (infile));
return false;
}
@@ -342,7 +342,7 @@ cat (
n_read = safe_read (input_desc, inbuf, insize);
if (n_read == SAFE_READ_ERROR)
{
- error (0, errno, "%s", infile);
+ error (0, errno, "%s", quote (infile));
write_pending (outbuf, &bpout);
newlines2 = newlines;
return false;
@@ -673,7 +673,7 @@ main (int argc, char **argv)
input_desc = open (infile, file_open_mode);
if (input_desc < 0)
{
- error (0, errno, "%s", infile);
+ error (0, errno, "%s", quote (infile));
ok = false;
continue;
}
@@ -681,7 +681,7 @@ main (int argc, char **argv)
if (fstat (input_desc, &stat_buf) < 0)
{
- error (0, errno, "%s", infile);
+ error (0, errno, "%s", quote (infile));
ok = false;
goto contin;
}
@@ -697,7 +697,7 @@ main (int argc, char **argv)
&& stat_buf.st_dev == out_dev && stat_buf.st_ino == out_ino
&& lseek (input_desc, 0, SEEK_CUR) < stat_buf.st_size)
{
- error (0, 0, _("%s: input file is output file"), infile);
+ error (0, 0, _("%s: input file is output file"), quote (infile));
ok = false;
goto contin;
}
@@ -755,7 +755,7 @@ main (int argc, char **argv)
contin:
if (!STREQ (infile, "-") && close (input_desc) < 0)
{
- error (0, errno, "%s", infile);
+ error (0, errno, "%s", quote (infile));
ok = false;
}
}