summaryrefslogtreecommitdiff
path: root/src/sort.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/sort.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/sort.c')
-rw-r--r--src/sort.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/sort.c b/src/sort.c
index c772c669b..09231c44b 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -408,7 +408,8 @@ static void die (char const *, char const *) ATTRIBUTE_NORETURN;
static void
die (char const *message, char const *file)
{
- error (0, errno, "%s: %s", message, file ? file : _("standard output"));
+ error (0, errno, "%s: %s", message,
+ quote (file ? file : _("standard output")));
exit (SORT_FAILURE);
}
@@ -722,12 +723,12 @@ reap (pid_t pid)
if (cpid < 0)
error (SORT_FAILURE, errno, _("waiting for %s [-d]"),
- compress_program);
+ quote (compress_program));
else if (0 < cpid && (0 < pid || delete_proc (cpid)))
{
if (! WIFEXITED (status) || WEXITSTATUS (status))
error (SORT_FAILURE, 0, _("%s [-d] terminated abnormally"),
- compress_program);
+ quote (compress_program));
--nprocs;
}
@@ -1176,7 +1177,7 @@ open_temp (struct tempnode *temp)
case -1:
if (errno != EMFILE)
error (SORT_FAILURE, errno, _("couldn't create process for %s -d"),
- compress_program);
+ quote (compress_program));
close (tempfd);
errno = EMFILE;
break;
@@ -1248,7 +1249,7 @@ zaptemp (char const *name)
cs_leave (cs);
if (unlink_status != 0)
- error (0, unlink_errno, _("warning: cannot remove: %s"), name);
+ error (0, unlink_errno, _("warning: cannot remove: %s"), quote (name));
if (! next)
temptail = pnode;
free (node);
@@ -4024,7 +4025,7 @@ static void incompatible_options (char const *) ATTRIBUTE_NORETURN;
static void
incompatible_options (char const *opts)
{
- error (SORT_FAILURE, 0, _("options '-%s' are incompatible"), opts);
+ error (SORT_FAILURE, 0, _("options '-%s' are incompatible"), (opts));
abort ();
}