]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
all: quote string arguments in error messages
authorPádraig Brady <P@draigBrady.com>
Tue, 27 Oct 2015 13:13:59 +0000 (13:13 +0000)
committerPádraig Brady <P@draigBrady.com>
Tue, 27 Oct 2015 17:24:54 +0000 (17:24 +0000)
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.

63 files changed:
NEWS
cfg.mk
src/base64.c
src/cat.c
src/chcon.c
src/chroot.c
src/cksum.c
src/comm.c
src/csplit.c
src/cut.c
src/date.c
src/dd.c
src/dircolors.c
src/du.c
src/env.c
src/expand.c
src/expr.c
src/fmt.c
src/fold.c
src/groups.c
src/id.c
src/install.c
src/join.c
src/kill.c
src/mknod.c
src/nice.c
src/nl.c
src/od.c
src/operand2sig.c
src/paste.c
src/pathchk.c
src/pinky.c
src/pr.c
src/printf.c
src/ptx.c
src/readlink.c
src/runcon.c
src/seq.c
src/shred.c
src/shuf.c
src/sort.c
src/split.c
src/stty.c
src/sum.c
src/tac.c
src/tail.c
src/tee.c
src/test.c
src/tsort.c
src/unexpand.c
src/uniq.c
src/uptime.c
src/users.c
src/wc.c
src/who.c
tests/du/bigtime.sh
tests/misc/dircolors.pl
tests/misc/printf-cov.pl
tests/misc/printf.sh
tests/misc/readlink-fp-loop.sh
tests/misc/shred-passes.sh
tests/misc/sort.pl
tests/misc/tsort.pl

diff --git a/NEWS b/NEWS
index 1997632f2fcafaf26edbd90b5751031697168862..0f2874301f3a161cba6b2ae011f7c6a1ed83be47 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,9 @@ GNU coreutils NEWS                                    -*- outline -*-
 
 ** Improvements
 
+  All utilities now quote user supplied arguments in error strings,
+  which avoids confusing error messages in the presence of '\r' chars etc.
+
   dircolors now supports globbing of TERM entries in its database.
   For example "TERM *256color*" is now supported.
 
diff --git a/cfg.mk b/cfg.mk
index 010a903e1eb96dc49fa17895f492a09a6cb68b7e..86373b8274a8691bce17da0d7dcdd13254963566 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -176,6 +176,17 @@ sc_prohibit_quotes_notation:
               exit 1; }  \
          || :
 
+# Files in src/ should quote all strings in error() output, so that
+# unexpected input chars like \r etc. don't corrupt the error.
+# In edge cases this can be avoided by putting the format string
+# on a separate line to the following arguments.
+sc_error_quotes:
+       @cd $(srcdir)/src && GIT_PAGER= git grep -n 'error *(.*%s.*, [^(]*);$$'\
+         *.c | grep -v quote \
+         && { echo '$(ME): '"Use quote() for error string arguments" 1>&2; \
+              exit 1; }  \
+         || :
+
 sc_sun_os_names:
        @grep -nEi \
            'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
index 1e43ff1869af3515f4e0b1df1a88fb0445b1fdbf..d5755ba5ee9117a1f7afb754e95ddb5aa959e7f2 100644 (file)
@@ -327,7 +327,7 @@ main (int argc, char **argv)
     {
       input_fh = fopen (infile, "rb");
       if (input_fh == NULL)
-        error (EXIT_FAILURE, errno, "%s", infile);
+        error (EXIT_FAILURE, errno, "%s", quote (infile));
     }
 
   fadvise (input_fh, FADVISE_SEQUENTIAL);
@@ -342,7 +342,7 @@ main (int argc, char **argv)
       if (STREQ (infile, "-"))
         error (EXIT_FAILURE, errno, _("closing standard input"));
       else
-        error (EXIT_FAILURE, errno, "%s", infile);
+        error (EXIT_FAILURE, errno, "%s", quote (infile));
     }
 
   return EXIT_SUCCESS;
index 948f1341bf55202f2815b235058b68b1fa63fc83..01a66c0a1d169f77924f3c1fda5724a6cbc30d17 100644 (file)
--- 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;
         }
     }
index bdf6137314fd95fa1f7e7852637bb2332a69f5fd..674d03366a5cc3a0dea645eb307869f27fa59f7d 100644 (file)
@@ -558,7 +558,7 @@ main (int argc, char **argv)
       specified_context = argv[optind++];
       if (security_check_context (se_const (specified_context)) < 0)
         error (EXIT_FAILURE, errno, _("invalid context: %s"),
-               quotearg_colon (specified_context));
+               quote (specified_context));
     }
 
   if (reference_file && component_specified)
index 42b4501780036088432007a6f5ce1853de4aea75..9551d934fa9b44fae27e3bb047b73bf380fbc3bb 100644 (file)
@@ -355,7 +355,7 @@ main (int argc, char **argv)
       char const *err = parse_user_spec (userspec, &uid, &gid, NULL, NULL);
 
       if (err && uid_unset (uid) && gid_unset (gid))
-        error (EXIT_CANCELED, errno, "%s", err);
+        error (EXIT_CANCELED, errno, "%s", (err));
     }
 
   /* If no gid is supplied or looked up, do so now.
index 458827b8264814b00735f7dbb74f5b53bd7a0bfc..2a19c678aca09675f4c476a041463696f23b2c30 100644 (file)
@@ -44,6 +44,7 @@
 #include <stdint.h>
 #include "system.h"
 #include "fadvise.h"
+#include "quote.h"
 #include "xfreopen.h"
 
 #ifdef CRCTAB
@@ -201,7 +202,7 @@ cksum (const char *file, bool print_name)
       fp = fopen (file, (O_BINARY ? "rb" : "r"));
       if (fp == NULL)
         {
-          error (0, errno, "%s", file);
+          error (0, errno, "%s", quote (file));
           return false;
         }
     }
@@ -213,7 +214,7 @@ cksum (const char *file, bool print_name)
       unsigned char *cp = buf;
 
       if (length + bytes_read < length)
-        error (EXIT_FAILURE, 0, _("%s: file too long"), file);
+        error (EXIT_FAILURE, 0, _("%s: file too long"), quote (file));
       length += bytes_read;
       while (bytes_read--)
         crc = (crc << 8) ^ crctab[((crc >> 24) ^ *cp++) & 0xFF];
@@ -223,7 +224,7 @@ cksum (const char *file, bool print_name)
 
   if (ferror (fp))
     {
-      error (0, errno, "%s", file);
+      error (0, errno, "%s", quote (file));
       if (!STREQ (file, "-"))
         fclose (fp);
       return false;
@@ -231,7 +232,7 @@ cksum (const char *file, bool print_name)
 
   if (!STREQ (file, "-") && fclose (fp) == EOF)
     {
-      error (0, errno, "%s", file);
+      error (0, errno, "%s", quote (file));
       return false;
     }
 
index ea7a28415f4f87deb04343f62ac4a17135ed6c66..a6fbde19665db0d4e10df114710c48364a0ade37 100644 (file)
@@ -274,13 +274,13 @@ compare_files (char **infiles)
       alt[i][2] = 0;
       streams[i] = (STREQ (infiles[i], "-") ? stdin : fopen (infiles[i], "r"));
       if (!streams[i])
-        error (EXIT_FAILURE, errno, "%s", infiles[i]);
+        error (EXIT_FAILURE, errno, "%s", quote (infiles[i]));
 
       fadvise (streams[i], FADVISE_SEQUENTIAL);
 
       thisline[i] = readlinebuffer (all_line[i][alt[i][0]], streams[i]);
       if (ferror (streams[i]))
-        error (EXIT_FAILURE, errno, "%s", infiles[i]);
+        error (EXIT_FAILURE, errno, "%s", quote (infiles[i]));
     }
 
   while (thisline[0] || thisline[1])
@@ -350,7 +350,7 @@ compare_files (char **infiles)
                            all_line[i][alt[i][1]], i + 1);
 
             if (ferror (streams[i]))
-              error (EXIT_FAILURE, errno, "%s", infiles[i]);
+              error (EXIT_FAILURE, errno, "%s", quote (infiles[i]));
 
             fill_up[i] = false;
           }
@@ -358,7 +358,7 @@ compare_files (char **infiles)
 
   for (i = 0; i < 2; i++)
     if (fclose (streams[i]) != 0)
-      error (EXIT_FAILURE, errno, "%s", infiles[i]);
+      error (EXIT_FAILURE, errno, "%s", quote (infiles[i]));
 }
 
 int
index 6b699428bab0de6636073c25e5a836a15b0b6167..6507c1177cc3f56403a904498d0d9da3dd3181fb 100644 (file)
@@ -671,7 +671,8 @@ write_to_file (uintmax_t last_line, bool ignore, int argnum)
 
   if (first_line > last_line)
     {
-      error (0, 0, _("%s: line number out of range"), global_argv[argnum]);
+      error (0, 0, _("%s: line number out of range"),
+             quote (global_argv[argnum]));
       cleanup_fatal ();
     }
 
@@ -682,7 +683,8 @@ write_to_file (uintmax_t last_line, bool ignore, int argnum)
       line = remove_line ();
       if (line == NULL)
         {
-          error (0, 0, _("%s: line number out of range"), global_argv[argnum]);
+          error (0, 0, _("%s: line number out of range"),
+                 quote (global_argv[argnum]));
           cleanup_fatal ();
         }
       if (!ignore)
@@ -967,7 +969,7 @@ create_output_file (void)
 
   if (! fopen_ok)
     {
-      error (0, fopen_errno, "%s", output_filename);
+      error (0, fopen_errno, "%s", quote (output_filename));
       cleanup_fatal ();
     }
   bytes_written = 0;
@@ -988,7 +990,7 @@ delete_all_files (bool in_signal_handler)
     {
       const char *name = make_filename (i);
       if (unlink (name) != 0 && !in_signal_handler)
-        error (0, errno, "%s", name);
+        error (0, errno, "%s", quote (name));
     }
 
   files_created = 0;
@@ -1010,7 +1012,7 @@ close_output_file (void)
         }
       if (fclose (output_stream) != 0)
         {
-          error (0, errno, "%s", output_filename);
+          error (0, errno, "%s", quote (output_filename));
           output_stream = NULL;
           cleanup_fatal ();
         }
@@ -1028,7 +1030,7 @@ close_output_file (void)
           sigprocmask (SIG_SETMASK, &oldset, NULL);
 
           if (! unlink_ok)
-            error (0, unlink_errno, "%s", output_filename);
+            error (0, unlink_errno, "%s", quote (output_filename));
         }
       else
         {
@@ -1080,7 +1082,8 @@ static void
 check_for_offset (struct control *p, const char *str, const char *num)
 {
   if (xstrtoimax (num, NULL, 10, &p->offset, "") != LONGINT_OK)
-    error (EXIT_FAILURE, 0, _("%s: integer expected after delimiter"), str);
+    error (EXIT_FAILURE, 0, _("%s: integer expected after delimiter"),
+           quote (str));
 }
 
 /* Given that the first character of command line arg STR is '{',
@@ -1096,7 +1099,8 @@ parse_repeat_count (int argnum, struct control *p, char *str)
 
   end = str + strlen (str) - 1;
   if (*end != '}')
-    error (EXIT_FAILURE, 0, _("%s: '}' is required in repeat count"), str);
+    error (EXIT_FAILURE, 0, _("%s: '}' is required in repeat count"),
+           quote (str));
   *end = '\0';
 
   if (str+1 == end-1 && *(str+1) == '*')
@@ -1107,7 +1111,7 @@ parse_repeat_count (int argnum, struct control *p, char *str)
         {
           error (EXIT_FAILURE, 0,
                  _("%s}: integer required between '{' and '}'"),
-                 global_argv[argnum]);
+                 quote (global_argv[argnum]));
         }
       p->repeat = val;
     }
@@ -1150,7 +1154,7 @@ extract_regexp (int argnum, bool ignore, char const *str)
   err = re_compile_pattern (str + 1, len, &p->re_compiled);
   if (err)
     {
-      error (0, 0, _("%s: invalid regular expression: %s"), str, err);
+      error (0, 0, _("%s: invalid regular expression: %s"), quote (str), err);
       cleanup_fatal ();
     }
 
@@ -1183,7 +1187,7 @@ parse_patterns (int argc, int start, char **argv)
           p->argnum = i;
 
           if (xstrtoumax (argv[i], NULL, 10, &val, "") != LONGINT_OK)
-            error (EXIT_FAILURE, 0, _("%s: invalid pattern"), argv[i]);
+            error (EXIT_FAILURE, 0, _("%s: invalid pattern"), quote (argv[i]));
           if (val == 0)
             error (EXIT_FAILURE, 0,
                    _("%s: line number must be greater than zero"),
index aac91ef5ec90f3c4e5df20fffd7cd2e8ad50ff43..b2087695d2882d0ec348b57352c82719fdd0efc7 100644 (file)
--- a/src/cut.c
+++ b/src/cut.c
@@ -34,6 +34,7 @@
 #include "fadvise.h"
 #include "getndelim2.h"
 #include "hash.h"
+#include "quote.h"
 #include "xstrndup.h"
 
 #include "set-fields.h"
@@ -444,7 +445,7 @@ cut_file (char const *file)
       stream = fopen (file, "r");
       if (stream == NULL)
         {
-          error (0, errno, "%s", file);
+          error (0, errno, "%s", quote (file));
           return false;
         }
     }
@@ -455,14 +456,14 @@ cut_file (char const *file)
 
   if (ferror (stream))
     {
-      error (0, errno, "%s", file);
+      error (0, errno, "%s", quote (file));
       return false;
     }
   if (STREQ (file, "-"))
     clearerr (stream);         /* Also clear EOF. */
   else if (fclose (stream) == EOF)
     {
-      error (0, errno, "%s", file);
+      error (0, errno, "%s", quote (file));
       return false;
     }
   return true;
index fae0256ad3443e50103f7e719335279812521657..732204ee805e817c8ff3d389e51c788f6baa6e71 100644 (file)
@@ -520,7 +520,7 @@ main (int argc, char **argv)
           if (reference != NULL)
             {
               if (stat (reference, &refstats) != 0)
-                error (EXIT_FAILURE, errno, "%s", reference);
+                error (EXIT_FAILURE, errno, "%s", quote (reference));
               when = get_stat_mtime (&refstats);
             }
           else
@@ -563,7 +563,8 @@ show_date (const char *format, struct timespec when, timezone_t tz)
   if (! tm)
     {
       char buf[INT_BUFSIZE_BOUND (intmax_t)];
-      error (0, 0, _("time %s is out of range"), timetostr (when.tv_sec, buf));
+      error (0, 0, _("time %s is out of range"),
+             quote (timetostr (when.tv_sec, buf)));
       return false;
     }
 
index e64729477101f471a31adcb6582d03d2274499cf..06beabf78bd34aa8e5f777858666ceb3b5e98168 100644 (file)
--- a/src/dd.c
+++ b/src/dd.c
@@ -1458,20 +1458,21 @@ scanargs (int argc, char *const *argv)
 
   if (output_flags & O_FULLBLOCK)
     {
-      error (0, 0, "%s: %s", _("invalid output flag"), "'fullblock'");
+      error (0, 0, "%s: %s", _("invalid output flag"), quote ("fullblock"));
       usage (EXIT_FAILURE);
     }
 
   if (input_flags & O_SEEK_BYTES)
     {
-      error (0, 0, "%s: %s", _("invalid input flag"), "'seek_bytes'");
+      error (0, 0, "%s: %s", _("invalid input flag"), quote ("seek_bytes"));
       usage (EXIT_FAILURE);
     }
 
   if (output_flags & (O_COUNT_BYTES | O_SKIP_BYTES))
     {
       error (0, 0, "%s: %s", _("invalid output flag"),
-             output_flags & O_COUNT_BYTES ? "'count_bytes'" : "'skip_bytes'");
+             quote (output_flags & O_COUNT_BYTES
+                    ? "count_bytes" : "skip_bytes"));
       usage (EXIT_FAILURE);
     }
 
index d0bd2e406d1b8270f54f1e2cfd5ce61d63295fee..f93b997a6011915fdc5e45653529ba168567d0d6 100644 (file)
@@ -285,7 +285,7 @@ dc_parse_stream (FILE *fp, const char *filename)
       if (arg == NULL)
         {
           error (0, 0, _("%s:%lu: invalid line;  missing second token"),
-                 filename, (unsigned long int) line_number);
+                 quote (filename), (unsigned long int) line_number);
           ok = false;
           free (keywd);
           continue;
@@ -376,7 +376,7 @@ dc_parse_file (const char *filename)
 
   if (! STREQ (filename, "-") && freopen (filename, "r", stdin) == NULL)
     {
-      error (0, errno, "%s", filename);
+      error (0, errno, "%s", quote (filename));
       return false;
     }
 
index 30378e55281df54e92f7daf984fa1402c7650fa4..0b405f47d4077aec0dfae5315486f0002e0adeca 100644 (file)
--- a/src/du.c
+++ b/src/du.c
@@ -380,7 +380,7 @@ show_date (const char *format, struct timespec when)
     {
       char buf[INT_BUFSIZE_BOUND (intmax_t)];
       char *when_str = timetostr (when.tv_sec, buf);
-      error (0, 0, _("time %s is out of range"), when_str);
+      error (0, 0, _("time %s is out of range"), quote (when_str));
       fputs (when_str, stdout);
       return;
     }
index 270d08e3b121a7fcf8551bcbd071a3d208050ada..681a6798a35f5861a2b9468b6180bf28c9c3c29b 100644 (file)
--- a/src/env.c
+++ b/src/env.c
@@ -156,6 +156,6 @@ main (int argc, char **argv)
   execvp (argv[optind], &argv[optind]);
 
   int exit_status = errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE;
-  error (0, errno, "%s", argv[optind]);
+  error (0, errno, "%s", quote (argv[optind]));
   return exit_status;
 }
index 0a40a1a8ea915a5301ffee18f5973eaab1539770..843bb87be712cc4468af60a7b1cde27df7e65777 100644 (file)
@@ -224,14 +224,14 @@ next_file (FILE *fp)
     {
       if (ferror (fp))
         {
-          error (0, errno, "%s", prev_file);
+          error (0, errno, "%s", quote (prev_file));
           exit_status = EXIT_FAILURE;
         }
       if (STREQ (prev_file, "-"))
         clearerr (fp);         /* Also clear EOF.  */
       else if (fclose (fp) != 0)
         {
-          error (0, errno, "%s", prev_file);
+          error (0, errno, "%s", quote (prev_file));
           exit_status = EXIT_FAILURE;
         }
     }
@@ -251,7 +251,7 @@ next_file (FILE *fp)
           fadvise (fp, FADVISE_SEQUENTIAL);
           return fp;
         }
-      error (0, errno, "%s", file);
+      error (0, errno, "%s", quote (file));
       exit_status = EXIT_FAILURE;
     }
   return NULL;
index b368e237c698626b63672da77a9a4f3bb2d3a180..536e681310e61d4283924a61e22638397c52f2d2 100644 (file)
@@ -466,7 +466,7 @@ toarith (VALUE *v)
         if (! looks_like_integer (s))
           return false;
         if (mpz_init_set_str (v->u.i, s, 10) != 0 && !HAVE_GMP)
-          error (EXPR_FAILURE, ERANGE, "%s", s);
+          error (EXPR_FAILURE, ERANGE, "%s", (s));
         free (s);
         v->type = integer;
         return true;
@@ -562,7 +562,7 @@ docolon (VALUE *sv, VALUE *pv)
     RE_SYNTAX_POSIX_BASIC & ~RE_CONTEXT_INVALID_DUP & ~RE_NO_EMPTY_RANGES;
   errmsg = re_compile_pattern (pv->u.s, strlen (pv->u.s), &re_buffer);
   if (errmsg)
-    error (EXPR_INVALID, 0, "%s", errmsg);
+    error (EXPR_INVALID, 0, "%s", (errmsg));
   re_buffer.newline_anchor = 0;
 
   matchlen = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs);
index b12c9b9edf17717ed106a3c6d76dd253786e9f24..f37f7cd8858790d416ed272ea1509da4bd8fab17 100644 (file)
--- a/src/fmt.c
+++ b/src/fmt.c
@@ -431,7 +431,7 @@ main (int argc, char **argv)
                   fmt (in_stream);
                   if (fclose (in_stream) == EOF)
                     {
-                      error (0, errno, "%s", file);
+                      error (0, errno, "%s", quote (file));
                       ok = false;
                     }
                 }
index 0955c09d94040dbd932f8eaf56988127e618fe1b..2f917f4009ec9e22be8a1258cbc23cf9a7890eb0 100644 (file)
@@ -25,6 +25,7 @@
 #include "system.h"
 #include "error.h"
 #include "fadvise.h"
+#include "quote.h"
 #include "xdectoint.h"
 
 #define TAB_WIDTH 8
@@ -136,7 +137,7 @@ fold_file (char const *filename, size_t width)
 
   if (istream == NULL)
     {
-      error (0, errno, "%s", filename);
+      error (0, errno, "%s", quote (filename));
       return false;
     }
 
@@ -221,14 +222,14 @@ fold_file (char const *filename, size_t width)
 
   if (ferror (istream))
     {
-      error (0, saved_errno, "%s", filename);
+      error (0, saved_errno, "%s", quote (filename));
       if (!STREQ (filename, "-"))
         fclose (istream);
       return false;
     }
   if (!STREQ (filename, "-") && fclose (istream) == EOF)
     {
-      error (0, errno, "%s", filename);
+      error (0, errno, "%s", quote (filename));
       return false;
     }
 
index 99eafb6c0c852f9801530faf789258017140d2d7..c3ed1c55fb45242af95933f40940892ec2c2e6ec 100644 (file)
@@ -27,6 +27,7 @@
 #include "system.h"
 #include "error.h"
 #include "group-list.h"
+#include "quote.h"
 
 /* The official name of this program (e.g., no 'g' prefix).  */
 #define PROGRAM_NAME "groups"
@@ -125,7 +126,8 @@ main (int argc, char **argv)
         {
           struct passwd *pwd = getpwnam (argv[optind]);
           if (pwd == NULL)
-            error (EXIT_FAILURE, 0, _("%s: no such user"), argv[optind]);
+            error (EXIT_FAILURE, 0, _("%s: no such user"),
+                   quote (argv[optind]));
           ruid = pwd->pw_uid;
           rgid = egid = pwd->pw_gid;
 
index 26f8e2d60231baa07db8ae35860799a72610aa76..d9094b5ca42485dc59c96a586eabf4a62a74483c 100644 (file)
--- a/src/id.c
+++ b/src/id.c
@@ -243,7 +243,7 @@ main (int argc, char **argv)
             }
         }
       if (pwd == NULL)
-        error (EXIT_FAILURE, 0, _("%s: no such user"), spec);
+        error (EXIT_FAILURE, 0, _("%s: no such user"), quote (spec));
       pw_name = xstrdup (pwd->pw_name);
       ruid = euid = pwd->pw_uid;
       rgid = egid = pwd->pw_gid;
index bfde21d63b358faf915757a28fe45249613f94a9..bbd67bc02aa113edc5b16fbfb557679c03af6fef 100644 (file)
@@ -532,7 +532,7 @@ strip (char const *name)
       break;
     case 0:                    /* Child. */
       execlp (strip_program, strip_program, name, NULL);
-      error (EXIT_FAILURE, errno, _("cannot run %s"), strip_program);
+      error (EXIT_FAILURE, errno, _("cannot run %s"), quote (strip_program));
       break;
     default:                   /* Parent. */
       if (waitpid (pid, &status, 0) < 0)
@@ -693,7 +693,7 @@ install_file_in_file (const char *from, const char *to,
     if (! strip (to))
       {
         if (unlink (to) != 0)  /* Cleanup.  */
-          error (EXIT_FAILURE, errno, _("cannot unlink %s"), to);
+          error (EXIT_FAILURE, errno, _("cannot unlink %s"), quote (to));
         return false;
       }
   if (x->preserve_timestamps && (strip_files || ! S_ISREG (from_sb.st_mode))
@@ -719,7 +719,7 @@ mkancesdirs_safe_wd (char const *from, char *to, struct cp_options *x)
 
   if (mkancesdirs (to, &wd, make_ancestor, x) == -1)
     {
-      error (0, errno, _("cannot create directory %s"), to);
+      error (0, errno, _("cannot create directory %s"), quote (to));
       status = EXIT_FAILURE;
     }
 
@@ -732,7 +732,7 @@ mkancesdirs_safe_wd (char const *from, char *to, struct cp_options *x)
         return false;
       if (restore_result < 0 && status == EXIT_SUCCESS)
         {
-          error (0, restore_errno, _("cannot create directory %s"), to);
+          error (0, restore_errno, _("cannot create directory %s"), quote (to));
           return false;
         }
     }
index 52e4b18b39d4116a0121abf3c08510a19534f018..ffef70f776d6f3572d000544899a21296a9154e8 100644 (file)
@@ -1183,18 +1183,18 @@ main (int argc, char **argv)
 
   fp1 = STREQ (g_names[0], "-") ? stdin : fopen (g_names[0], "r");
   if (!fp1)
-    error (EXIT_FAILURE, errno, "%s", g_names[0]);
+    error (EXIT_FAILURE, errno, "%s", quote (g_names[0]));
   fp2 = STREQ (g_names[1], "-") ? stdin : fopen (g_names[1], "r");
   if (!fp2)
-    error (EXIT_FAILURE, errno, "%s", g_names[1]);
+    error (EXIT_FAILURE, errno, "%s", quote (g_names[1]));
   if (fp1 == fp2)
     error (EXIT_FAILURE, errno, _("both files cannot be standard input"));
   join (fp1, fp2);
 
   if (fclose (fp1) != 0)
-    error (EXIT_FAILURE, errno, "%s", g_names[0]);
+    error (EXIT_FAILURE, errno, "%s", quote (g_names[0]));
   if (fclose (fp2) != 0)
-    error (EXIT_FAILURE, errno, "%s", g_names[1]);
+    error (EXIT_FAILURE, errno, "%s", quote (g_names[1]));
 
   if (issued_disorder_warning[0] || issued_disorder_warning[1])
     return EXIT_FAILURE;
index 83016ed3ca76365d94a788e6a1747cc3f36857e1..98b270f752ef62bfd7f9427af2898afe5c609b7e 100644 (file)
@@ -26,6 +26,7 @@
 #include "error.h"
 #include "sig2str.h"
 #include "operand2sig.h"
+#include "quote.h"
 
 /* The official name of this program (e.g., no 'g' prefix).  */
 #define PROGRAM_NAME "kill"
@@ -202,12 +203,12 @@ send_signals (int signum, char *const *argv)
 
       if (errno == ERANGE || pid != n || arg == endp || *endp)
         {
-          error (0, 0, _("%s: invalid process id"), arg);
+          error (0, 0, _("%s: invalid process id"), quote (arg));
           status = EXIT_FAILURE;
         }
       else if (kill (pid, signum) != 0)
         {
-          error (0, errno, "%s", arg);
+          error (0, errno, "%s", quote (arg));
           status = EXIT_FAILURE;
         }
     }
@@ -265,7 +266,7 @@ main (int argc, char **argv)
       case 's':
         if (0 <= signum)
           {
-            error (0, 0, _("%s: multiple signals specified"), optarg);
+            error (0, 0, _("%s: multiple signals specified"), quote (optarg));
             usage (EXIT_FAILURE);
           }
         signum = operand2sig (optarg, signame);
index 73342ce2942a1f1cd0b58574cfdd32994934f71e..ffade1b7ae7bfd7040b594ac61fa25277b7274d9 100644 (file)
@@ -242,7 +242,8 @@ main (int argc, char **argv)
         device = makedev (i_major, i_minor);
 #ifdef NODEV
         if (device == NODEV)
-          error (EXIT_FAILURE, 0, _("invalid device %s %s"), s_major, s_minor);
+          error (EXIT_FAILURE, 0, _("invalid device %s %s"),
+                 s_major, s_minor);
 #endif
 
         if (set_security_context)
index 121d1c090d1f2879361152cb2ea59f2bcdf70eb3..71f2931366c3475c04f8adffc8f0f84c007b5fce 100644 (file)
@@ -215,6 +215,6 @@ main (int argc, char **argv)
   execvp (argv[i], &argv[i]);
 
   int exit_status = errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE;
-  error (0, errno, "%s", argv[i]);
+  error (0, errno, "%s", quote (argv[i]));
   return exit_status;
 }
index 1132af3981d41d0d238629fd87ee4bfbddb1cced..f431d983960d7f8e5efca99c7f713df3a121272d 100644 (file)
--- a/src/nl.c
+++ b/src/nl.c
@@ -255,7 +255,7 @@ build_type_arg (char const **typep,
         RE_SYNTAX_POSIX_BASIC & ~RE_CONTEXT_INVALID_DUP & ~RE_NO_EMPTY_RANGES;
       errmsg = re_compile_pattern (optarg, strlen (optarg), regexp);
       if (errmsg)
-        error (EXIT_FAILURE, 0, "%s", errmsg);
+        error (EXIT_FAILURE, 0, "%s", (errmsg));
       break;
     default:
       rval = false;
@@ -426,7 +426,7 @@ nl_file (char const *file)
       stream = fopen (file, "r");
       if (stream == NULL)
         {
-          error (0, errno, "%s", file);
+          error (0, errno, "%s", quote (file));
           return false;
         }
     }
@@ -437,14 +437,14 @@ nl_file (char const *file)
 
   if (ferror (stream))
     {
-      error (0, errno, "%s", file);
+      error (0, errno, "%s", quote (file));
       return false;
     }
   if (STREQ (file, "-"))
     clearerr (stream);         /* Also clear EOF. */
   else if (fclose (stream) == EOF)
     {
-      error (0, errno, "%s", file);
+      error (0, errno, "%s", quote (file));
       return false;
     }
   return true;
index 0ca3ca7871525ed2e4e91d4d5131fa33971f9a89..643fb3878489becf0b4bdaf9a171bec250ff42e9 100644 (file)
--- a/src/od.c
+++ b/src/od.c
@@ -921,7 +921,7 @@ open_next_file (void)
           in_stream = fopen (input_filename, (O_BINARY ? "rb" : "r"));
           if (in_stream == NULL)
             {
-              error (0, errno, "%s", input_filename);
+              error (0, errno, "%s", quote (input_filename));
               ok = false;
             }
         }
@@ -950,14 +950,14 @@ check_and_close (int in_errno)
     {
       if (ferror (in_stream))
         {
-          error (0, in_errno, _("%s: read error"), input_filename);
+          error (0, in_errno, _("%s: read error"), quote (input_filename));
           if (! STREQ (file_list[-1], "-"))
             fclose (in_stream);
           ok = false;
         }
       else if (! STREQ (file_list[-1], "-") && fclose (in_stream) != 0)
         {
-          error (0, errno, "%s", input_filename);
+          error (0, errno, "%s", quote (input_filename));
           ok = false;
         }
 
@@ -1092,7 +1092,7 @@ skip (uintmax_t n_skip)
 
       else   /* cannot fstat() file */
         {
-          error (0, errno, "%s", input_filename);
+          error (0, errno, "%s", quote (input_filename));
           ok = false;
         }
 
@@ -1692,7 +1692,7 @@ main (int argc, char **argv)
               /* The minimum string length may be no larger than SIZE_MAX,
                  since we may allocate a buffer of this size.  */
               if (SIZE_MAX < tmp)
-                error (EXIT_FAILURE, 0, _("%s is too large"), optarg);
+                error (EXIT_FAILURE, 0, _("%s is too large"), quote (optarg));
 
               string_min = tmp;
             }
@@ -1773,7 +1773,7 @@ main (int argc, char **argv)
               if (s_err != LONGINT_OK)
                 xstrtol_fatal (s_err, oi, c, long_options, optarg);
               if (SIZE_MAX < w_tmp)
-                error (EXIT_FAILURE, 0, _("%s is too large"), optarg);
+                error (EXIT_FAILURE, 0, _("%s is too large"), quote (optarg));
               desired_width = w_tmp;
             }
           break;
index bc3b2279ebdfe8cdb07425dc4b2f16ec5e6edf72..d410387786f6ffbdc4a785176fa5e2d015d967ed 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "system.h"
 #include "error.h"
+#include "quote.h"
 #include "sig2str.h"
 #include "operand2sig.h"
 
@@ -66,7 +67,7 @@ operand2sig (char const *operand, char *signame)
 
   if (signum < 0 || sig2str (signum, signame) != 0)
     {
-      error (0, 0, _("%s: invalid signal"), operand);
+      error (0, 0, _("%s: invalid signal"), quote (operand));
       return -1;
     }
 
index 7a5b5d7ab89b4a23fe8e0b722362a2d70e9f2409..fd6f033f6b17fdaa357ca40e4953c22f5917730f 100644 (file)
@@ -43,6 +43,7 @@
 #include "system.h"
 #include "error.h"
 #include "fadvise.h"
+#include "quote.h"
 #include "quotearg.h"
 
 /* The official name of this program (e.g., no 'g' prefix).  */
@@ -209,7 +210,7 @@ paste_parallel (size_t nfiles, char **fnamptr)
         {
           fileptr[files_open] = fopen (fnamptr[files_open], "r");
           if (fileptr[files_open] == NULL)
-            error (EXIT_FAILURE, errno, "%s", fnamptr[files_open]);
+            error (EXIT_FAILURE, errno, "%s", quote (fnamptr[files_open]));
           else if (fileno (fileptr[files_open]) == STDIN_FILENO)
             opened_stdin = true;
           fadvise (fileptr[files_open], FADVISE_SEQUENTIAL);
@@ -267,14 +268,14 @@ paste_parallel (size_t nfiles, char **fnamptr)
                 {
                   if (ferror (fileptr[i]))
                     {
-                      error (0, err, "%s", fnamptr[i]);
+                      error (0, err, "%s", quote (fnamptr[i]));
                       ok = false;
                     }
                   if (fileptr[i] == stdin)
                     clearerr (fileptr[i]); /* Also clear EOF. */
                   else if (fclose (fileptr[i]) == EOF)
                     {
-                      error (0, errno, "%s", fnamptr[i]);
+                      error (0, errno, "%s", quote (fnamptr[i]));
                       ok = false;
                     }
 
@@ -365,7 +366,7 @@ paste_serial (size_t nfiles, char **fnamptr)
           fileptr = fopen (*fnamptr, "r");
           if (fileptr == NULL)
             {
-              error (0, errno, "%s", *fnamptr);
+              error (0, errno, "%s", quote (*fnamptr));
               ok = false;
               continue;
             }
@@ -411,14 +412,14 @@ paste_serial (size_t nfiles, char **fnamptr)
 
       if (ferror (fileptr))
         {
-          error (0, saved_errno, "%s", *fnamptr);
+          error (0, saved_errno, "%s", quote (*fnamptr));
           ok = false;
         }
       if (is_stdin)
         clearerr (fileptr);    /* Also clear EOF. */
       else if (fclose (fileptr) == EOF)
         {
-          error (0, errno, "%s", *fnamptr);
+          error (0, errno, "%s", quote (*fnamptr));
           ok = false;
         }
     }
index e05ecf7f4c4c35eaa94e279507e07cd497ae1bb3..d9f3bceb6893381df20606d06eb2b27749cb7aae 100644 (file)
@@ -290,7 +290,7 @@ validate_file_name (char *file, bool check_basic_portability,
         file_exists = true;
       else if (errno != ENOENT || filelen == 0)
         {
-          error (0, errno, "%s", file);
+          error (0, errno, "%s", quote (file));
           return false;
         }
     }
@@ -393,7 +393,7 @@ validate_file_name (char *file, bool check_basic_portability,
 
                   default:
                     *start = '\0';
-                    error (0, errno, "%s", dir);
+                    error (0, errno, "%s", quote (dir));
                     *start = c;
                     return false;
                   }
index 71650bfae7d8cb5bb0547de2df4fd8d0548e17e4..f969e5b97af21a115d542682f8ee203f7003e167 100644 (file)
@@ -27,6 +27,7 @@
 #include "canon-host.h"
 #include "error.h"
 #include "hard-locale.h"
+#include "quote.h"
 #include "readutmp.h"
 
 /* The official name of this program (e.g., no 'g' prefix).  */
@@ -468,7 +469,7 @@ short_pinky (const char *filename,
   STRUCT_UTMP *utmp_buf = NULL;
 
   if (read_utmp (filename, &n_users, &utmp_buf, 0) != 0)
-    error (EXIT_FAILURE, errno, "%s", filename);
+    error (EXIT_FAILURE, errno, "%s", quote (filename));
 
   scan_entries (n_users, utmp_buf, argc_names, argv_names);
 
index 887e1258425e711112e3467727bfa3e42d495117..d16b18613a2a29f0c739041b788f4b1313b08122 100644 (file)
--- a/src/pr.c
+++ b/src/pr.c
@@ -1465,7 +1465,7 @@ open_file (char *name, COLUMN *p)
     {
       failed_opens = true;
       if (!ignore_failed_opens)
-        error (0, errno, "%s", name);
+        error (0, errno, "%s", quote (name));
       return false;
     }
   fadvise (p->fp, FADVISE_SEQUENTIAL);
@@ -1489,9 +1489,9 @@ close_file (COLUMN *p)
   if (p->status == CLOSED)
     return;
   if (ferror (p->fp))
-    error (EXIT_FAILURE, errno, "%s", p->name);
+    error (EXIT_FAILURE, errno, "%s", quote (p->name));
   if (fileno (p->fp) != STDIN_FILENO && fclose (p->fp) != 0)
-    error (EXIT_FAILURE, errno, "%s", p->name);
+    error (EXIT_FAILURE, errno, "%s", quote (p->name));
 
   if (!parallel_files)
     {
index 4260519dcf84866c53d976f503bc3fc320f20f55..3e68b995f72616573c7df9c05418fd55f38e7898 100644 (file)
@@ -139,15 +139,15 @@ verify_numeric (const char *s, const char *end)
 {
   if (errno)
     {
-      error (0, errno, "%s", s);
+      error (0, errno, "%s", quote (s));
       exit_status = EXIT_FAILURE;
     }
   else if (*end)
     {
       if (s == end)
-        error (0, 0, _("%s: expected a numeric value"), s);
+        error (0, 0, _("%s: expected a numeric value"), quote (s));
       else
-        error (0, 0, _("%s: value not completely converted"), s);
+        error (0, 0, _("%s: value not completely converted"), quote (s));
       exit_status = EXIT_FAILURE;
     }
 }
@@ -545,7 +545,7 @@ print_formatted (const char *format, int argc, char **argv)
                     field_width = width;
                   else
                     error (EXIT_FAILURE, 0, _("invalid field width: %s"),
-                           *argv);
+                           quote (*argv));
                   ++argv;
                   --argc;
                 }
@@ -580,7 +580,7 @@ print_formatted (const char *format, int argc, char **argv)
                         }
                       else if (INT_MAX < prec)
                         error (EXIT_FAILURE, 0, _("invalid precision: %s"),
-                               *argv);
+                               quote (*argv));
                       else
                         precision = prec;
                       ++argv;
index 2ccabb73432bebf353dc2ffc89ccd5319b575bab..c489301a3779b08243d66d7ea7e4a9c751eee837 100644 (file)
--- a/src/ptx.c
+++ b/src/ptx.c
@@ -2076,7 +2076,7 @@ main (int argc, char **argv)
       if (optind < argc)
         {
           if (! freopen (argv[optind], "w", stdout))
-            error (EXIT_FAILURE, errno, "%s", argv[optind]);
+            error (EXIT_FAILURE, errno, "%s", quote (argv[optind]));
           optind++;
         }
 
index 1778f639a593dc1e02c09c5b5fac0ba774916c37..2b61fda92fa998de435991767b70e082376a953e 100644 (file)
@@ -25,6 +25,7 @@
 #include "canonicalize.h"
 #include "error.h"
 #include "areadlink.h"
+#include "quote.h"
 
 /* The official name of this program (e.g., no 'g' prefix).  */
 #define PROGRAM_NAME "readlink"
@@ -170,7 +171,7 @@ main (int argc, char **argv)
         {
           status = EXIT_FAILURE;
           if (verbose)
-            error (0, errno, "%s", fname);
+            error (0, errno, "%s", quote (fname));
         }
     }
 
index 33250308da699a74f7c621a8fa491c1d7e78c080..ecb12985a6d72a20fb53d8946c5ea398d777b8fd 100644 (file)
@@ -200,7 +200,7 @@ main (int argc, char **argv)
       con = context_new (context);
       if (!con)
         error (EXIT_FAILURE, errno, _("failed to create security context: %s"),
-               quotearg_colon (context));
+               quote (context));
     }
   else
     {
@@ -233,13 +233,17 @@ main (int argc, char **argv)
         error (EXIT_FAILURE, errno, _("failed to create security context: %s"),
                quotearg_colon (cur_context));
       if (user && context_user_set (con, user))
-        error (EXIT_FAILURE, errno, _("failed to set new user %s"), user);
+        error (EXIT_FAILURE, errno, _("failed to set new user: %s"),
+               quote (user));
       if (type && context_type_set (con, type))
-        error (EXIT_FAILURE, errno, _("failed to set new type %s"), type);
+        error (EXIT_FAILURE, errno, _("failed to set new type: %s"),
+               quote (type));
       if (range && context_range_set (con, range))
-        error (EXIT_FAILURE, errno, _("failed to set new range %s"), range);
+        error (EXIT_FAILURE, errno, _("failed to set new range: %s"),
+               quote (range));
       if (role && context_role_set (con, role))
-        error (EXIT_FAILURE, errno, _("failed to set new role %s"), role);
+        error (EXIT_FAILURE, errno, _("failed to set new role: %s"),
+               quote (role));
     }
 
   if (security_check_context (context_str (con)) < 0)
@@ -255,6 +259,6 @@ main (int argc, char **argv)
   execvp (argv[optind], argv + optind);
 
   int exit_status = errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE;
-  error (0, errno, "%s", argv[optind]);
+  error (0, errno, "%s", quote (argv[optind]));
   return exit_status;
 }
index 2426c4de386711dbcaf5a62d5b8591cf610f430f..1f2a66a7b7f0790e29b13816617e84753f832184 100644 (file)
--- a/src/seq.c
+++ b/src/seq.c
@@ -139,7 +139,7 @@ scan_arg (const char *arg)
 
   if (! xstrtold (arg, NULL, &ret.value, c_strtold))
     {
-      error (0, 0, _("invalid floating point argument: %s"), arg);
+      error (0, 0, _("invalid floating point argument: %s"), quote (arg));
       usage (EXIT_FAILURE);
     }
 
index 2857835a22be5351bbc8955bd13a8b0ba78a4a8e..6029d37e3fbf3800b183075485cc499977c1e4c5 100644 (file)
@@ -90,6 +90,7 @@
 #include "error.h"
 #include "fcntl--.h"
 #include "human.h"
+#include "quote.h"
 #include "quotearg.h"          /* For quotearg_colon */
 #include "randint.h"
 #include "randread.h"
@@ -340,7 +341,7 @@ dosync (int fd, char const *qname)
   err = errno;
   if ( ! ignorable_sync_errno (err))
     {
-      error (0, err, _("%s: fdatasync failed"), qname);
+      error (0, err, _("%s: fdatasync failed"), quote (qname));
       errno = err;
       return -1;
     }
@@ -351,7 +352,7 @@ dosync (int fd, char const *qname)
   err = errno;
   if ( ! ignorable_sync_errno (err))
     {
-      error (0, err, _("%s: fsync failed"), qname);
+      error (0, err, _("%s: fsync failed"), quote (qname));
       errno = err;
       return -1;
     }
@@ -469,7 +470,7 @@ dopass (int fd, struct stat const *st, char const *qname, off_t *sizep,
 
   if (! dorewind (fd, st))
     {
-      error (0, errno, _("%s: cannot rewind"), qname);
+      error (0, errno, _("%s: cannot rewind"), quote (qname));
       other_error = true;
       goto free_pattern_mem;
     }
@@ -489,7 +490,8 @@ dopass (int fd, struct stat const *st, char const *qname, off_t *sizep,
   /* Set position if first status update */
   if (n)
     {
-      error (0, 0, _("%s: pass %lu/%lu (%s)..."), qname, k, n, pass_string);
+      error (0, 0, _("%s: pass %lu/%lu (%s)..."),
+             quote (qname), k, n, pass_string);
       thresh = time (NULL) + VERBOSE_UPDATE;
       previous_human_offset = "";
     }
@@ -541,7 +543,7 @@ dopass (int fd, struct stat const *st, char const *qname, off_t *sizep,
                       continue;
                     }
                   error (0, errnum, _("%s: error writing at offset %s"),
-                         qname, umaxtostr (offset + soff, buf));
+                         quote (qname), umaxtostr (offset + soff, buf));
 
                   /* 'shred' is often used on bad media, before throwing it
                      out.  Thus, it shouldn't give up on bad blocks.  This
@@ -561,7 +563,7 @@ dopass (int fd, struct stat const *st, char const *qname, off_t *sizep,
                           write_error = true;
                           continue;
                         }
-                      error (0, errno, _("%s: lseek failed"), qname);
+                      error (0, errno, _("%s: lseek failed"), quote (qname));
                     }
                   other_error = true;
                   goto free_pattern_mem;
@@ -573,7 +575,7 @@ dopass (int fd, struct stat const *st, char const *qname, off_t *sizep,
 
       if (OFF_T_MAX - offset < soff)
         {
-          error (0, 0, _("%s: file too large"), qname);
+          error (0, 0, _("%s: file too large"), quote (qname));
           other_error = true;
           goto free_pattern_mem;
         }
@@ -598,7 +600,7 @@ dopass (int fd, struct stat const *st, char const *qname, off_t *sizep,
             {
               if (! known (size))
                 error (0, 0, _("%s: pass %lu/%lu (%s)...%s"),
-                       qname, k, n, pass_string, human_offset);
+                       quote (qname), k, n, pass_string, human_offset);
               else
                 {
                   uintmax_t off = offset;
@@ -614,8 +616,8 @@ dopass (int fd, struct stat const *st, char const *qname, off_t *sizep,
                   if (done)
                     human_offset = human_size;
                   error (0, 0, _("%s: pass %lu/%lu (%s)...%s/%s %d%%"),
-                         qname, k, n, pass_string, human_offset, human_size,
-                         percent);
+                         quote (qname), k, n, pass_string, human_offset,
+                         human_size, percent);
                 }
 
               strcpy (previous_offset_buf, human_offset);
@@ -872,7 +874,7 @@ do_wipefd (int fd, char const *qname, struct randint_source *s,
 
   if (fstat (fd, &st))
     {
-      error (0, errno, _("%s: fstat failed"), qname);
+      error (0, errno, _("%s: fstat failed"), quote (qname));
       return false;
     }
 
@@ -883,12 +885,12 @@ do_wipefd (int fd, char const *qname, struct randint_source *s,
       || S_ISFIFO (st.st_mode)
       || S_ISSOCK (st.st_mode))
     {
-      error (0, 0, _("%s: invalid file type"), qname);
+      error (0, 0, _("%s: invalid file type"), quote (qname));
       return false;
     }
   else if (S_ISREG (st.st_mode) && st.st_size < 0)
     {
-      error (0, 0, _("%s: file has negative size"), qname);
+      error (0, 0, _("%s: file has negative size"), quote (qname));
       return false;
     }
 
@@ -982,7 +984,7 @@ do_wipefd (int fd, char const *qname, struct randint_source *s,
   if (flags->remove_file && ftruncate (fd, 0) != 0
       && S_ISREG (st.st_mode))
     {
-      error (0, errno, _("%s: error truncating"), qname);
+      error (0, errno, _("%s: error truncating"), quote (qname));
       ok = false;
       goto wipefd_out;
     }
@@ -1002,12 +1004,13 @@ wipefd (int fd, char const *qname, struct randint_source *s,
 
   if (fd_flags < 0)
     {
-      error (0, errno, _("%s: fcntl failed"), qname);
+      error (0, errno, _("%s: fcntl failed"), quote (qname));
       return false;
     }
   if (fd_flags & O_APPEND)
     {
-      error (0, 0, _("%s: cannot shred append-only file descriptor"), qname);
+      error (0, 0, _("%s: cannot shred append-only file descriptor"),
+             quote (qname));
       return false;
     }
   return do_wipefd (fd, qname, s, flags);
@@ -1091,7 +1094,7 @@ wipename (char *oldname, char const *qoldname, struct Options const *flags)
     dir_fd = open (dir, O_RDONLY | O_DIRECTORY | O_NOCTTY | O_NONBLOCK);
 
   if (flags->verbose)
-    error (0, 0, _("%s: removing"), qoldname);
+    error (0, 0, _("%s: removing"), quote (qoldname));
 
   while ((flags->remove_file != remove_unlink) && len)
     {
@@ -1115,7 +1118,8 @@ wipename (char *oldname, char const *qoldname, struct Options const *flags)
                        * be quoted only the first time.
                        */
                       char const *old = (first ? qoldname : oldname);
-                      error (0, 0, _("%s: renamed to %s"), old, newname);
+                      error (0, 0, _("%s: renamed to %s"),
+                             quote_n (0, old), quote_n (1, newname));
                       first = false;
                     }
                   memcpy (oldname + (base - newname), base, len + 1);
@@ -1137,18 +1141,18 @@ wipename (char *oldname, char const *qoldname, struct Options const *flags)
     }
   if (unlink (oldname) != 0)
     {
-      error (0, errno, _("%s: failed to remove"), qoldname);
+      error (0, errno, _("%s: failed to remove"), quote (qoldname));
       ok = false;
     }
   else if (flags->verbose)
-    error (0, 0, _("%s: removed"), qoldname);
+    error (0, 0, _("%s: removed"), quote (qoldname));
   if (0 <= dir_fd)
     {
       if (dosync (dir_fd, qdir) != 0)
         ok = false;
       if (close (dir_fd) != 0)
         {
-          error (0, errno, _("%s: failed to close"), qdir);
+          error (0, errno, _("%s: failed to close"), quote (qdir));
           ok = false;
         }
     }
@@ -1184,14 +1188,14 @@ wipefile (char *name, char const *qname,
     fd = open (name, O_WRONLY | O_NOCTTY | O_BINARY);
   if (fd < 0)
     {
-      error (0, errno, _("%s: failed to open for writing"), qname);
+      error (0, errno, _("%s: failed to open for writing"), quote (qname));
       return false;
     }
 
   ok = do_wipefd (fd, qname, s, flags);
   if (close (fd) != 0)
     {
-      error (0, errno, _("%s: failed to close"), qname);
+      error (0, errno, _("%s: failed to close"), quote (qname));
       ok = false;
     }
   if (ok && flags->remove_file)
index ff2337d3402f7c3c469ce864cb661d213c103c4d..040b00028a970f9b0f1644e5a6e6036bc8aff1a7 100644 (file)
@@ -520,7 +520,7 @@ main (int argc, char **argv)
       if (n_operands == 1)
         if (! (STREQ (operand[0], "-") || ! head_lines
                || freopen (operand[0], "r", stdin)))
-          error (EXIT_FAILURE, errno, "%s", operand[0]);
+          error (EXIT_FAILURE, errno, "%s", quote (operand[0]));
 
       fadvise (stdin, FADVISE_SEQUENTIAL);
 
index c772c669b1cadfccb7e6d763377a8232b7573ee2..09231c44b304e86b26aed2535433b165cc698707 100644 (file)
@@ -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 ();
 }
 
index 1e6bec61a354766696a23ef73af91e07bca458cd..f16cb518e7cc53492b0f645ffdeab939a478a453 100644 (file)
@@ -291,11 +291,11 @@ input_file_size (int fd, off_t size, char *buf, size_t bufsize)
           if (n_read == 0)
             break;
           if (n_read == SAFE_READ_ERROR)
-            error (EXIT_FAILURE, errno, "%s", infile);
+            error (EXIT_FAILURE, errno, "%s", quote (infile));
           size += n_read;
         }
       if (bufsize <= size && lseek (fd, - size, SEEK_CUR) < 0)
-        error (EXIT_FAILURE, errno, "%s", infile);
+        error (EXIT_FAILURE, errno, "%s", quote (infile));
     }
 
   return size;
@@ -384,7 +384,7 @@ new_name:
         char *dir = dir_name (outfile);
         long name_max = pathconf (dir, _PC_NAME_MAX);
         if (0 <= name_max && name_max < base_len (last_component (outfile)))
-          error (EXIT_FAILURE, ENAMETOOLONG, "%s", outfile);
+          error (EXIT_FAILURE, ENAMETOOLONG, "%s", quote (outfile));
         free (dir);
       }
 #endif
@@ -496,11 +496,11 @@ static void
 closeout (FILE *fp, int fd, pid_t pid, char const *name)
 {
   if (fp != NULL && fclose (fp) != 0 && ! ignorable (errno))
-    error (EXIT_FAILURE, errno, "%s", name);
+    error (EXIT_FAILURE, errno, "%s", quote (name));
   if (fd >= 0)
     {
       if (fp == NULL && close (fd) < 0)
-        error (EXIT_FAILURE, errno, "%s", name);
+        error (EXIT_FAILURE, errno, "%s", quote (name));
       int j;
       for (j = 0; j < n_open_pipes; ++j)
         {
@@ -526,7 +526,7 @@ closeout (FILE *fp, int fd, pid_t pid, char const *name)
                 sprintf (signame, "%d", sig);
               error (sig + 128, 0,
                      _("with FILE=%s, signal %s from command: %s"),
-                     name, signame, filter_command);
+                     quote (name), signame, filter_command);
             }
         }
       else if (WIFEXITED (wstatus))
@@ -534,7 +534,7 @@ closeout (FILE *fp, int fd, pid_t pid, char const *name)
           int ex = WEXITSTATUS (wstatus);
           if (ex != 0)
             error (ex, 0, _("with FILE=%s, exit %d from command: %s"),
-                   name, ex, filter_command);
+                   quote (name), ex, filter_command);
         }
       else
         {
@@ -559,10 +559,10 @@ cwrite (bool new_file_flag, const char *bp, size_t bytes)
       closeout (NULL, output_desc, filter_pid, outfile);
       next_file_name ();
       if ((output_desc = create (outfile)) < 0)
-        error (EXIT_FAILURE, errno, "%s", outfile);
+        error (EXIT_FAILURE, errno, "%s", quote (outfile));
     }
   if (full_write (output_desc, bp, bytes) != bytes && ! ignorable (errno))
-    error (EXIT_FAILURE, errno, "%s", outfile);
+    error (EXIT_FAILURE, errno, "%s", quote (outfile));
 }
 
 /* Split into pieces of exactly N_BYTES bytes.
@@ -592,7 +592,7 @@ bytes_split (uintmax_t n_bytes, char *buf, size_t bufsize, size_t initial_read,
         {
           n_read = safe_read (STDIN_FILENO, buf, bufsize);
           if (n_read == SAFE_READ_ERROR)
-            error (EXIT_FAILURE, errno, "%s", infile);
+            error (EXIT_FAILURE, errno, "%s", quote (infile));
         }
       bp_out = buf;
       to_read = n_read;
@@ -651,7 +651,7 @@ lines_split (uintmax_t n_lines, char *buf, size_t bufsize)
     {
       n_read = safe_read (STDIN_FILENO, buf, bufsize);
       if (n_read == SAFE_READ_ERROR)
-        error (EXIT_FAILURE, errno, "%s", infile);
+        error (EXIT_FAILURE, errno, "%s", quote (infile));
       bp = bp_out = buf;
       eob = bp + n_read;
       *eob = eolchar;
@@ -700,7 +700,7 @@ line_bytes_split (uintmax_t n_bytes, char *buf, size_t bufsize)
     {
       n_read = safe_read (STDIN_FILENO, buf, bufsize);
       if (n_read == SAFE_READ_ERROR)
-        error (EXIT_FAILURE, errno, "%s", infile);
+        error (EXIT_FAILURE, errno, "%s", quote (infile));
       size_t n_left = n_read;
       char *sob = buf;
       while (n_left)
@@ -823,7 +823,7 @@ lines_chunk_split (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
           initial_read -= start;
         }
       else if (lseek (STDIN_FILENO, start, SEEK_CUR) < 0)
-        error (EXIT_FAILURE, errno, "%s", infile);
+        error (EXIT_FAILURE, errno, "%s", quote (infile));
       n_written = start;
       chunk_no = k - 1;
       chunk_end = chunk_no * chunk_size - 1;
@@ -842,7 +842,7 @@ lines_chunk_split (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
         {
           n_read = safe_read (STDIN_FILENO, buf, bufsize);
           if (n_read == SAFE_READ_ERROR)
-            error (EXIT_FAILURE, errno, "%s", infile);
+            error (EXIT_FAILURE, errno, "%s", quote (infile));
         }
       if (n_read == 0)
         break; /* eof.  */
@@ -937,7 +937,7 @@ bytes_chunk_extract (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
       initial_read -= start;
     }
   else if (lseek (STDIN_FILENO, start, SEEK_CUR) < 0)
-    error (EXIT_FAILURE, errno, "%s", infile);
+    error (EXIT_FAILURE, errno, "%s", quote (infile));
 
   while (start < end)
     {
@@ -951,7 +951,7 @@ bytes_chunk_extract (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
         {
           n_read = safe_read (STDIN_FILENO, buf, bufsize);
           if (n_read == SAFE_READ_ERROR)
-            error (EXIT_FAILURE, errno, "%s", infile);
+            error (EXIT_FAILURE, errno, "%s", quote (infile));
         }
       if (n_read == 0)
         break; /* eof.  */
@@ -1023,7 +1023,7 @@ ofile_open (of_t *files, size_t i_check, size_t nfiles)
             break;
 
           if (!(errno == EMFILE || errno == ENFILE))
-            error (EXIT_FAILURE, errno, "%s", files[i_check].of_name);
+            error (EXIT_FAILURE, errno, "%s", quote (files[i_check].of_name));
 
           file_limit = true;
 
@@ -1033,18 +1033,19 @@ ofile_open (of_t *files, size_t i_check, size_t nfiles)
               i_reopen = i_reopen ? i_reopen - 1 : nfiles - 1;
               /* No more open files to close, exit with E[NM]FILE.  */
               if (i_reopen == i_check)
-                error (EXIT_FAILURE, errno, "%s", files[i_check].of_name);
+                error (EXIT_FAILURE, errno, "%s",
+                       quote (files[i_check].of_name));
             }
 
           if (fclose (files[i_reopen].ofile) != 0)
-            error (EXIT_FAILURE, errno, "%s", files[i_reopen].of_name);
+            error (EXIT_FAILURE, errno, "%s", quote (files[i_reopen].of_name));
           files[i_reopen].ofile = NULL;
           files[i_reopen].ofd = OFD_APPEND;
         }
 
       files[i_check].ofd = fd;
       if (!(files[i_check].ofile = fdopen (fd, "a")))
-        error (EXIT_FAILURE, errno, "%s", files[i_check].of_name);
+        error (EXIT_FAILURE, errno, "%s", quote (files[i_check].of_name));
       files[i_check].opid = filter_pid;
       filter_pid = 0;
     }
@@ -1093,7 +1094,7 @@ lines_rr (uintmax_t k, uintmax_t n, char *buf, size_t bufsize)
       char *bp = buf, *eob;
       size_t n_read = safe_read (STDIN_FILENO, buf, bufsize);
       if (n_read == SAFE_READ_ERROR)
-        error (EXIT_FAILURE, errno, "%s", infile);
+        error (EXIT_FAILURE, errno, "%s", quote (infile));
       else if (n_read == 0)
         break; /* eof.  */
       eob = buf + n_read;
@@ -1139,18 +1140,27 @@ lines_rr (uintmax_t k, uintmax_t n, char *buf, size_t bufsize)
                      an 8% performance benefit, due to reduced data copying.  */
                   if (full_write (files[i_file].ofd, bp, to_write) != to_write
                       && ! ignorable (errno))
-                    error (EXIT_FAILURE, errno, "%s", files[i_file].of_name);
+                    {
+                      error (EXIT_FAILURE, errno, "%s",
+                             quote (files[i_file].of_name));
+                    }
                 }
               else if (fwrite (bp, to_write, 1, files[i_file].ofile) != 1
                        && ! ignorable (errno))
-                error (EXIT_FAILURE, errno, "%s", files[i_file].of_name);
+                {
+                  error (EXIT_FAILURE, errno, "%s",
+                         quote (files[i_file].of_name));
+                }
               if (! ignorable (errno))
                 wrote = true;
 
               if (file_limit)
                 {
                   if (fclose (files[i_file].ofile) != 0)
-                    error (EXIT_FAILURE, errno, "%s", files[i_file].of_name);
+                    {
+                      error (EXIT_FAILURE, errno, "%s",
+                             quote (files[i_file].of_name));
+                    }
                   files[i_file].ofile = NULL;
                   files[i_file].ofd = OFD_APPEND;
                 }
@@ -1394,7 +1404,7 @@ main (int argc, char **argv)
                 {
                   error (0, 0,
                          _("%s: invalid start value for numerical suffix"),
-                         optarg);
+                         quote (optarg));
                   usage (EXIT_FAILURE);
                 }
               else
@@ -1493,7 +1503,7 @@ main (int argc, char **argv)
   /* Get the optimal block size of input device and make a buffer.  */
 
   if (fstat (STDIN_FILENO, &in_stat_buf) != 0)
-    error (EXIT_FAILURE, errno, "%s", infile);
+    error (EXIT_FAILURE, errno, "%s", quote (infile));
 
   bool specified_buf_size = !! in_blk_size;
   if (! specified_buf_size)
@@ -1595,7 +1605,7 @@ main (int argc, char **argv)
   IF_LINT (free (b));
 
   if (close (STDIN_FILENO) != 0)
-    error (EXIT_FAILURE, errno, "%s", infile);
+    error (EXIT_FAILURE, errno, "%s", quote (infile));
   closeout (NULL, output_desc, filter_pid, outfile);
 
   return EXIT_SUCCESS;
index c0057f2d7ef5e30b9f12d1262e93e7be9af3061b..2ed3939d505167fab53c8db8cb94eae7a6265024 100644 (file)
@@ -1169,17 +1169,17 @@ main (int argc, char **argv)
       int fdflags;
       device_name = file_name;
       if (fd_reopen (STDIN_FILENO, device_name, O_RDONLY | O_NONBLOCK, 0) < 0)
-        error (EXIT_FAILURE, errno, "%s", device_name);
+        error (EXIT_FAILURE, errno, "%s", quote (device_name));
       if ((fdflags = fcntl (STDIN_FILENO, F_GETFL)) == -1
           || fcntl (STDIN_FILENO, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
         error (EXIT_FAILURE, errno, _("%s: couldn't reset non-blocking mode"),
-               device_name);
+               quote (device_name));
     }
   else
     device_name = _("standard input");
 
   if (tcgetattr (STDIN_FILENO, &mode))
-    error (EXIT_FAILURE, errno, "%s", device_name);
+    error (EXIT_FAILURE, errno, "%s", quote (device_name));
 
   if (verbose_output || recoverable_output || noargs)
     {
@@ -1281,7 +1281,7 @@ main (int argc, char **argv)
               if (ioctl (STDIN_FILENO, TIOCEXT, &val) != 0)
                 {
                   error (EXIT_FAILURE, errno, _("%s: error setting %s"),
-                         device_name, quote (arg));
+                         quote_n (0, device_name), quote_n (1, arg));
                 }
             }
 #endif
@@ -1362,7 +1362,7 @@ main (int argc, char **argv)
       static struct termios new_mode;
 
       if (tcsetattr (STDIN_FILENO, TCSADRAIN, &mode))
-        error (EXIT_FAILURE, errno, "%s", device_name);
+        error (EXIT_FAILURE, errno, "%s", quote (device_name));
 
       /* POSIX (according to Zlotnick's book) tcsetattr returns zero if
          it performs *any* of the requested operations.  This means it
@@ -1372,7 +1372,7 @@ main (int argc, char **argv)
          compare them to the requested ones.  */
 
       if (tcgetattr (STDIN_FILENO, &new_mode))
-        error (EXIT_FAILURE, errno, "%s", device_name);
+        error (EXIT_FAILURE, errno, "%s", quote (device_name));
 
       /* Normally, one shouldn't use memcmp to compare structures that
          may have 'holes' containing uninitialized data, but we have been
@@ -1399,7 +1399,7 @@ main (int argc, char **argv)
             {
               error (EXIT_FAILURE, 0,
                      _("%s: unable to perform all requested operations"),
-                     device_name);
+                     quote (device_name));
 #ifdef TESTING
               {
                 size_t i;
@@ -1679,7 +1679,7 @@ set_window_size (int rows, int cols, char const *device_name)
   if (get_win_size (STDIN_FILENO, &win))
     {
       if (errno != EINVAL)
-        error (EXIT_FAILURE, errno, "%s", device_name);
+        error (EXIT_FAILURE, errno, "%s", quote (device_name));
       memset (&win, 0, sizeof (win));
     }
 
@@ -1721,16 +1721,16 @@ set_window_size (int rows, int cols, char const *device_name)
       win.ws_col = 1;
 
       if (ioctl (STDIN_FILENO, TIOCSWINSZ, (char *) &win))
-        error (EXIT_FAILURE, errno, "%s", device_name);
+        error (EXIT_FAILURE, errno, "%s", quote (device_name));
 
       if (ioctl (STDIN_FILENO, TIOCSSIZE, (char *) &ttysz))
-        error (EXIT_FAILURE, errno, "%s", device_name);
+        error (EXIT_FAILURE, errno, "%s", quote (device_name));
       return;
     }
 # endif
 
   if (ioctl (STDIN_FILENO, TIOCSWINSZ, (char *) &win))
-    error (EXIT_FAILURE, errno, "%s", device_name);
+    error (EXIT_FAILURE, errno, "%s", quote (device_name));
 }
 
 static void
@@ -1741,10 +1741,11 @@ display_window_size (bool fancy, char const *device_name)
   if (get_win_size (STDIN_FILENO, &win))
     {
       if (errno != EINVAL)
-        error (EXIT_FAILURE, errno, "%s", device_name);
+        error (EXIT_FAILURE, errno, "%s", quote (device_name));
       if (!fancy)
         error (EXIT_FAILURE, 0,
-               _("%s: no size information for this device"), device_name);
+               _("%s: no size information for this device"),
+               quote (device_name));
     }
   else
     {
index 51956c61fcc42d3ccf5c25f6280116c92eed46db..0c74779ccc939ba4595c703124510c2df367ff49 100644 (file)
--- a/src/sum.c
+++ b/src/sum.c
@@ -27,6 +27,7 @@
 #include "error.h"
 #include "fadvise.h"
 #include "human.h"
+#include "quote.h"
 #include "safe-read.h"
 #include "xfreopen.h"
 
@@ -105,7 +106,7 @@ bsd_sum_file (const char *file, int print_name)
       fp = fopen (file, (O_BINARY ? "rb" : "r"));
       if (fp == NULL)
         {
-          error (0, errno, "%s", file);
+          error (0, errno, "%s", quote (file));
           return false;
         }
     }
@@ -122,7 +123,7 @@ bsd_sum_file (const char *file, int print_name)
 
   if (ferror (fp))
     {
-      error (0, errno, "%s", file);
+      error (0, errno, "%s", quote (file));
       if (!is_stdin)
         fclose (fp);
       return false;
@@ -130,7 +131,7 @@ bsd_sum_file (const char *file, int print_name)
 
   if (!is_stdin && fclose (fp) != 0)
     {
-      error (0, errno, "%s", file);
+      error (0, errno, "%s", quote (file));
       return false;
     }
 
@@ -175,7 +176,7 @@ sysv_sum_file (const char *file, int print_name)
       fd = open (file, O_RDONLY | O_BINARY);
       if (fd == -1)
         {
-          error (0, errno, "%s", file);
+          error (0, errno, "%s", quote (file));
           return false;
         }
     }
@@ -190,7 +191,7 @@ sysv_sum_file (const char *file, int print_name)
 
       if (bytes_read == SAFE_READ_ERROR)
         {
-          error (0, errno, "%s", file);
+          error (0, errno, "%s", quote (file));
           if (!is_stdin)
             close (fd);
           return false;
@@ -203,7 +204,7 @@ sysv_sum_file (const char *file, int print_name)
 
   if (!is_stdin && close (fd) != 0)
     {
-      error (0, errno, "%s", file);
+      error (0, errno, "%s", quote (file));
       return false;
     }
 
@@ -270,6 +271,6 @@ main (int argc, char **argv)
       ok &= sum_func (argv[optind], files_given);
 
   if (have_read_stdin && fclose (stdin) == EOF)
-    error (EXIT_FAILURE, errno, "-");
+    error (EXIT_FAILURE, errno, "%s", quote ("-"));
   return ok ? EXIT_SUCCESS : EXIT_FAILURE;
 }
index 57e7e761d3a5c7af419380175e749ae15b873c22..1029de63b472ebc4855d3d812f27730f15dbf6bf 100644 (file)
--- a/src/tac.c
+++ b/src/tac.c
@@ -660,7 +660,7 @@ main (int argc, char **argv)
       error_message = re_compile_pattern (separator, strlen (separator),
                                           &compiled_separator);
       if (error_message)
-        error (EXIT_FAILURE, 0, "%s", error_message);
+        error (EXIT_FAILURE, 0, "%s", (error_message));
     }
   else
     match_length = sentinel_length = strlen (separator);
index dfa7e30dfffbe24dc7e9e37cc12927ecc6e0bd49..6c5dd3a9d0abc1f28f24538eb5a70b8f5bd99c1c 100644 (file)
@@ -360,7 +360,7 @@ close_fd (int fd, const char *filename)
 {
   if (fd != -1 && fd != STDIN_FILENO && close (fd))
     {
-      error (0, errno, _("closing %s (fd=%d)"), filename, fd);
+      error (0, errno, _("closing %s (fd=%d)"), quote (filename), fd);
     }
 }
 
@@ -446,15 +446,15 @@ xlseek (int fd, off_t offset, int whence, char const *filename)
     {
     case SEEK_SET:
       error (0, errno, _("%s: cannot seek to offset %s"),
-             filename, s);
+             quote (filename), s);
       break;
     case SEEK_CUR:
       error (0, errno, _("%s: cannot seek to relative offset %s"),
-             filename, s);
+             quote (filename), s);
       break;
     case SEEK_END:
       error (0, errno, _("%s: cannot seek to end-relative offset %s"),
-             filename, s);
+             quote (filename), s);
       break;
     default:
       abort ();
@@ -975,9 +975,7 @@ recheck (struct File_spec *f, bool blocking)
             }
         }
       else if (prev_errnum != errno)
-        {
-          error (0, errno, "%s", pretty_name (f));
-        }
+        error (0, errno, "%s", quote (pretty_name (f)));
     }
   else if (!IS_TAILABLE_FILE_TYPE (new_stats.st_mode))
     {
@@ -1152,7 +1150,8 @@ tail_forever (struct File_spec *f, size_t n_files, double sleep_interval)
                     }
                   else
                     error (EXIT_FAILURE, errno,
-                           _("%s: cannot change nonblocking mode"), name);
+                           _("%s: cannot change nonblocking mode"),
+                           quote (name));
                 }
               else
                 f[i].blocking = blocking;
@@ -1164,7 +1163,7 @@ tail_forever (struct File_spec *f, size_t n_files, double sleep_interval)
                 {
                   f[i].fd = -1;
                   f[i].errnum = errno;
-                  error (0, errno, "%s", name);
+                  error (0, errno, "%s", quote (name));
                   close (fd); /* ignore failure */
                   continue;
                 }
@@ -1197,7 +1196,7 @@ tail_forever (struct File_spec *f, size_t n_files, double sleep_interval)
                  (in which case we ignore new data <= size).  */
               if (S_ISREG (mode) && stats.st_size < f[i].size)
                 {
-                  error (0, 0, _("%s: file truncated"), name);
+                  error (0, 0, _("%s: file truncated"), quote (name));
                   /* Assume the file was truncated to 0,
                      and therefore output all "new" data.  */
                   xlseek (fd, 0, SEEK_SET, name);
@@ -1339,7 +1338,7 @@ check_fspec (struct File_spec *fspec, struct File_spec **prev_fspec)
      separate events for truncate() and write().  */
   if (S_ISREG (fspec->mode) && stats.st_size < fspec->size)
     {
-      error (0, 0, _("%s: file truncated"), name);
+      error (0, 0, _("%s: file truncated"), quote (name));
       xlseek (fspec->fd, 0, SEEK_SET, name);
       fspec->size = 0;
     }
@@ -1913,7 +1912,7 @@ tail_file (struct File_spec *f, uintmax_t n_units)
             {
               error (0, 0, _("%s: cannot follow end of this type of file;\
  giving up on this name"),
-                     pretty_name (f));
+                     quote (pretty_name (f)));
               ok = false;
               f->errnum = -1;
               f->ignore = true;
index 350a201efbac672e797233436517e19c0c6d92c2..37105c3ca4cfd892c6f34d0191ae99596fba8a4c 100644 (file)
--- a/src/tee.c
+++ b/src/tee.c
@@ -25,6 +25,7 @@
 #include "argmatch.h"
 #include "error.h"
 #include "fadvise.h"
+#include "quote.h"
 #include "stdio--.h"
 #include "xfreopen.h"
 
@@ -170,7 +171,7 @@ main (int argc, char **argv)
 
   ok = tee_files (argc - optind, &argv[optind]);
   if (close (STDIN_FILENO) != 0)
-    error (EXIT_FAILURE, errno, _("standard input"));
+    error (EXIT_FAILURE, errno, "%s", _("standard input"));
 
   return ok ? EXIT_SUCCESS : EXIT_FAILURE;
 }
@@ -218,7 +219,7 @@ tee_files (int nfiles, char **files)
         {
           error (output_error == output_error_exit
                  || output_error == output_error_exit_nopipe,
-                 errno, "%s", files[i]);
+                 errno, "%s", quote (files[i]));
           ok = false;
         }
       else
@@ -251,7 +252,7 @@ tee_files (int nfiles, char **files)
               {
                 error (output_error == output_error_exit
                        || output_error == output_error_exit_nopipe,
-                       w_errno, "%s", files[i]);
+                       w_errno, "%s", quote (files[i]));
               }
             descriptors[i] = NULL;
             if (fail)
@@ -270,7 +271,7 @@ tee_files (int nfiles, char **files)
   for (i = 1; i <= nfiles; i++)
     if (descriptors[i] && fclose (descriptors[i]) != 0)
       {
-        error (0, errno, "%s", files[i]);
+        error (0, errno, "%s", quote (files[i]));
         ok = false;
       }
 
index 80cc679c94c31ca91385abf0870d87e718028f1e..65226c535a4b19acba4c03d490b5acbba2cc5ec9 100644 (file)
@@ -243,7 +243,7 @@ term (void)
         test_syntax_error (_("')' expected"), NULL);
       else
         if (argv[pos][0] != ')' || argv[pos][1])
-          test_syntax_error (_("')' expected, found %s"), argv[pos]);
+          test_syntax_error (_("')' expected, found %s"), quote (argv[pos]));
       advance (false);
     }
 
@@ -259,7 +259,7 @@ term (void)
       if (test_unop (argv[pos]))
         value = unary_operator ();
       else
-        test_syntax_error (_("%s: unary operator expected"), argv[pos]);
+        test_syntax_error (_("%s: unary operator expected"), quote (argv[pos]));
     }
   else
     {
@@ -366,7 +366,7 @@ binary_operator (bool l_is_l)
         }
 
       /* FIXME: is this dead code? */
-      test_syntax_error (_("unknown binary operator"), argv[op]);
+      test_syntax_error (_("%s: unknown binary operator"), quote (argv[op]));
     }
 
   if (argv[op][0] == '='
@@ -617,7 +617,7 @@ two_arguments (void)
       if (test_unop (argv[pos]))
         value = unary_operator ();
       else
-        test_syntax_error (_("%s: unary operator expected"), argv[pos]);
+        test_syntax_error (_("%s: unary operator expected"), quote (argv[pos]));
     }
   else
     beyond ();
@@ -645,7 +645,7 @@ three_arguments (void)
   else if (STREQ (argv[pos + 1], "-a") || STREQ (argv[pos + 1], "-o"))
     value = expr ();
   else
-    test_syntax_error (_("%s: binary operator expected"), argv[pos+1]);
+    test_syntax_error (_("%s: binary operator expected"), quote (argv[pos+1]));
   return (value);
 }
 
index 0533451dad165bffe008350373e17587744e7bef..dc9bed5e940a21327ef64a72835e7f3d0b9d8c1d 100644 (file)
@@ -351,7 +351,7 @@ detect_loop (struct item *k)
                         {
                           struct item *tmp = loop->qlink;
 
-                          error (0, 0, "%s", loop->str);
+                          error (0, 0, "%s", (loop->str));
 
                           /* Until we encounter K again.  */
                           if (loop == k)
@@ -445,7 +445,7 @@ tsort (const char *file)
   root = new_item (NULL);
 
   if (!is_stdin && ! freopen (file, "r", stdin))
-    error (EXIT_FAILURE, errno, "%s", file);
+    error (EXIT_FAILURE, errno, "%s", quote (file));
 
   fadvise (stdin, FADVISE_SEQUENTIAL);
 
@@ -473,7 +473,7 @@ tsort (const char *file)
 
   if (k != NULL)
     error (EXIT_FAILURE, 0, _("%s: input contains an odd number of tokens"),
-           file);
+           quote (file));
 
   /* T1. Initialize (N <- n).  */
   walk_tree (root, count_items);
@@ -518,7 +518,7 @@ tsort (const char *file)
       if (n_strings > 0)
         {
           /* The input contains a loop.  */
-          error (0, 0, _("%s: input contains a loop:"), file);
+          error (0, 0, _("%s: input contains a loop:"), quote (file));
           ok = false;
 
           /* Print the loop and remove a relation to break it.  */
index e0f7c22aaa385c13964c9fb8514c94e7c8f992e1..14ff84f2b24cc37996c95d48e12080f4acff394f 100644 (file)
@@ -243,14 +243,14 @@ next_file (FILE *fp)
     {
       if (ferror (fp))
         {
-          error (0, errno, "%s", prev_file);
+          error (0, errno, "%s", quote (prev_file));
           exit_status = EXIT_FAILURE;
         }
       if (STREQ (prev_file, "-"))
         clearerr (fp);         /* Also clear EOF.  */
       else if (fclose (fp) != 0)
         {
-          error (0, errno, "%s", prev_file);
+          error (0, errno, "%s", quote (prev_file));
           exit_status = EXIT_FAILURE;
         }
     }
@@ -270,7 +270,7 @@ next_file (FILE *fp)
           fadvise (fp, FADVISE_SEQUENTIAL);
           return fp;
         }
-      error (0, errno, "%s", file);
+      error (0, errno, "%s", quote (file));
       exit_status = EXIT_FAILURE;
     }
   return NULL;
index 7b77dd3b02407f47de9e0825b1be192adf4fe5a0..c85be6ee811b84bb384e1d24fb1412d3458eee29 100644 (file)
@@ -327,9 +327,9 @@ check_file (const char *infile, const char *outfile, char delimiter)
   struct linebuffer *thisline, *prevline;
 
   if (! (STREQ (infile, "-") || freopen (infile, "r", stdin)))
-    error (EXIT_FAILURE, errno, "%s", infile);
+    error (EXIT_FAILURE, errno, "%s", quote (infile));
   if (! (STREQ (outfile, "-") || freopen (outfile, "w", stdout)))
-    error (EXIT_FAILURE, errno, "%s", outfile);
+    error (EXIT_FAILURE, errno, "%s", quote (outfile));
 
   fadvise (stdin, FADVISE_SEQUENTIAL);
 
@@ -462,7 +462,7 @@ check_file (const char *infile, const char *outfile, char delimiter)
 
  closefiles:
   if (ferror (stdin) || fclose (stdin) != 0)
-    error (EXIT_FAILURE, 0, _("error reading %s"), infile);
+    error (EXIT_FAILURE, 0, _("error reading %s"), quote (infile));
 
   /* stdout is handled via the atexit-invoked close_stdout function.  */
 
index 51233860e1b47656e5db40275aa6c3e1d507bade..b35fd074242635c43be3b0e1262de9fa91dd5551 100644 (file)
@@ -180,7 +180,7 @@ uptime (const char *filename, int options)
 
 #if HAVE_UTMPX_H || HAVE_UTMP_H
   if (read_utmp (filename, &n_users, &utmp_buf, options) != 0)
-    error (EXIT_FAILURE, errno, "%s", filename);
+    error (EXIT_FAILURE, errno, "%s", quote (filename));
 #endif
 
   print_uptime (n_users, utmp_buf);
index 353753cac799146b34632cd2582c0db5c22c4572..2a66101f96c3ffd209b07e19c8a1d20c11878f17 100644 (file)
@@ -88,7 +88,7 @@ users (const char *filename, int options)
   STRUCT_UTMP *utmp_buf;
 
   if (read_utmp (filename, &n_users, &utmp_buf, options) != 0)
-    error (EXIT_FAILURE, errno, "%s", filename);
+    error (EXIT_FAILURE, errno, "%s", quote (filename));
 
   list_entries_users (n_users, utmp_buf);
 
index 9fbaee7bc1e1bb8eccabb832e01e3e381c3eb0ea..fc66dfc73568a12c0ef442274f6854cc9a65eda1 100644 (file)
--- a/src/wc.c
+++ b/src/wc.c
@@ -259,7 +259,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus, off_t current_pos)
         {
           if (bytes_read == SAFE_READ_ERROR)
             {
-              error (0, errno, "%s", file);
+              error (0, errno, "%s", quote (file));
               ok = false;
               break;
             }
@@ -275,7 +275,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus, off_t current_pos)
         {
           if (bytes_read == SAFE_READ_ERROR)
             {
-              error (0, errno, "%s", file);
+              error (0, errno, "%s", quote (file));
               ok = false;
               break;
             }
@@ -343,7 +343,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus, off_t current_pos)
 # endif
           if (bytes_read == SAFE_READ_ERROR)
             {
-              error (0, errno, "%s", file);
+              error (0, errno, "%s", quote (file));
               ok = false;
               break;
             }
@@ -464,7 +464,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus, off_t current_pos)
           const char *p = buf;
           if (bytes_read == SAFE_READ_ERROR)
             {
-              error (0, errno, "%s", file);
+              error (0, errno, "%s", quote (file));
               ok = false;
               break;
             }
@@ -541,7 +541,7 @@ wc_file (char const *file, struct fstatus *fstatus)
       int fd = open (file, O_RDONLY | O_BINARY);
       if (fd == -1)
         {
-          error (0, errno, "%s", file);
+          error (0, errno, "%s", quote (file));
           return false;
         }
       else
@@ -549,7 +549,7 @@ wc_file (char const *file, struct fstatus *fstatus)
           bool ok = wc (fd, file, fstatus, 0);
           if (close (fd) != 0)
             {
-              error (0, errno, "%s", file);
+              error (0, errno, "%s", quote (file));
               return false;
             }
           return ok;
index 0a09411f4abec3d63cbb49a5b1b30f2a453a0e90..2260bc1e9c26d5581e218b637aa2c043ff12be23 100644 (file)
--- a/src/who.c
+++ b/src/who.c
@@ -620,7 +620,7 @@ who (const char *filename, int options)
   STRUCT_UTMP *utmp_buf;
 
   if (read_utmp (filename, &n_users, &utmp_buf, options) != 0)
-    error (EXIT_FAILURE, errno, "%s", filename);
+    error (EXIT_FAILURE, errno, "%s", quote (filename));
 
   if (short_list)
     list_entries_who (n_users, utmp_buf);
index ad484f8185a8980483f98c90c5ab87394e9addf5..95fa1932daf47522709183c72e8160bc789d7e76 100755 (executable)
@@ -37,7 +37,7 @@ case "$future_time" in
 esac || skip_ "file system cannot represent big time stamps"
 
 printf "0\t$bignum\tfuture\n" > exp || framework_failure_
-printf "du: time $bignum is out of range\n" > err_ok || framework_failure_
+printf "du: time '$bignum' is out of range\n" > err_ok || framework_failure_
 
 du --time future >out 2>err || fail=1
 
index 2e6f27d88971fd25a5f630999db2a80a3d3261d1..2ef6228de324e32bc983badc27edf8503b3ebb53 100755 (executable)
@@ -26,7 +26,7 @@ use strict;
 my @Tests =
     (
      ['a', '-b', {IN => {k => "exec\n"}},
-      {ERR => "dircolors: k:1: invalid line;  missing second token\n"},
+      {ERR => "dircolors: 'k':1: invalid line;  missing second token\n"},
       {EXIT => 1}],
      ['quote', '-b', {IN => "exec 'echo Hello;:'\n"},
       {OUT => "LS_COLORS='ex='\\''echo Hello;\\:'\\'':';\n"
index 4be97971886562b2d33499f97efdb1f853562def..eb4adf3bdf1138c55538b0512d3c3b713a55e08e 100755 (executable)
@@ -46,9 +46,9 @@ my @Tests =
   ['d-vwvp', '%*.*d 3 2 15',  {OUT=>" 15"}],
   ['d-neg-prec', '%.*d -3 15',  {OUT=>"15"}],
   ['d-big-prec', "%.*d $pow_2_31 15",  # INT_MAX
-   {EXIT=>1}, {ERR=>"$prog: invalid precision: $pow_2_31\n"}],
+   {EXIT=>1}, {ERR=>"$prog: invalid precision: '$pow_2_31'\n"}],
   ['d-big-fwidth', "%*d $pow_2_31 15",  # INT_MAX
-   {EXIT=>1}, {ERR=>"$prog: invalid field width: $pow_2_31\n"}],
+   {EXIT=>1}, {ERR=>"$prog: invalid field width: '$pow_2_31'\n"}],
   ['F',  '%F  1',  {OUT=>"1.000000"}],
   ['LF', '%LF 1',  {OUT=>"1.000000"}],
   ['E',  '%E  2',  {OUT=>"2.000000E+00"}],
@@ -76,12 +76,12 @@ my @Tests =
     #   no-num: Invalid argument         (FreeBSD6)
     #   no-num: expected a numeric value (glibc, Solaris 10)
     {ERR_SUBST => 's/Invalid argument$/expected a numeric value/'},
-    {ERR=>"$prog: no-num: expected a numeric value\n"}],
+    {ERR=>"$prog: 'no-num': expected a numeric value\n"}],
   ['d-bad-suffix', '%d 9z', {OUT=>'9'}, {EXIT=>1},
-    {ERR=>"$prog: 9z: value not completely converted\n"}],
+    {ERR=>"$prog: '9z': value not completely converted\n"}],
   ['d-out-of-range', '%d '.('9'x30), {EXIT=>1},
     {OUT=>"inaccurate"}, {OUT_SUBST => 's/\d+/inaccurate/'},
-    {ERR=>"$prog: 9...9\n"}, {ERR_SUBST => 's/9+.*/9...9/'}],
+    {ERR=>"$prog: 9...9\n"}, {ERR_SUBST => "s/'9+.*/9...9/"}],
   ['excess', 'B 1', {OUT=>'B'},
     {ERR=>"$prog: warning: ignoring excess arguments, starting with '1'\n"}],
   ['percent', '%%', {OUT=>'%'}],
index 87ca489f266c1bd12344bb1e4e2a1ba7c876943c..10b7a8c5d682f5f677e162ba0eb546f96f04b68f 100755 (executable)
@@ -119,8 +119,8 @@ sed 's/: Invalid.*/: expected a numeric value/' err > k && mv k err
 
 cat <<EOF > exp_err
 printf: warning: ": character(s) following character constant have been ignored
-printf: ": expected a numeric value
-printf: a: expected a numeric value
+printf: '"': expected a numeric value
+printf: 'a': expected a numeric value
 EOF
 
 compare exp out || fail=1
index 1c4428b949b957c3fedd0f006ca408f3bbb767e7..d3e1a1eaf062a8439b2774eeb49cf7ba8fc0023c 100755 (executable)
@@ -42,10 +42,10 @@ ln -sf ../s/1 d/2 || framework_failure_
 readlink -v -e p/1 2> out && fail=1
 readlink_msg=$(cat out)
 case $readlink_msg in
-  'readlink: p/1: '*) ;;
+  "readlink: 'p/1': "*) ;;
   *) fail=1;;
 esac
-symlink_loop_msg=${readlink_msg#'readlink: p/1: '}
+symlink_loop_msg=${readlink_msg#"readlink: 'p/1': "}
 
 # Exercise the hash table code.
 ln -nsf ../s/3 d/2 || framework_failure_
@@ -62,7 +62,7 @@ compare exp out || fail=1
 # A trivial loop
 ln -s loop loop
 readlink -v -e loop 2> out && fail=1
-echo "readlink: loop: $symlink_loop_msg" > exp || framework_failure_
+echo "readlink: 'loop': $symlink_loop_msg" > exp || framework_failure_
 compare exp out || fail=1
 
 Exit $fail
index 64216fd8a39363021a4938cfdb482ddadaf16fe3..c19cc7655374389eb36155df72e74885c662182b 100755 (executable)
@@ -24,12 +24,12 @@ print_ver_ shred
 # 3 random passes and a single rename.
 printf 1 > f || framework_failure_
 echo "\
-shred: f: pass 1/3 (random)...
-shred: f: pass 2/3 (random)...
-shred: f: pass 3/3 (random)...
-shred: f: removing
-shred: f: renamed to 0
-shred: f: removed" > exp || framework_failure_
+shred: 'f': pass 1/3 (random)...
+shred: 'f': pass 2/3 (random)...
+shred: 'f': pass 3/3 (random)...
+shred: 'f': removing
+shred: 'f': renamed to '0'
+shred: 'f': removed" > exp || framework_failure_
 
 shred -v -u f 2>out || fail=1
 compare exp out || fail=1
@@ -39,9 +39,9 @@ compare exp out || fail=1
 # to bypass the data passes
 touch f || framework_failure_
 echo "\
-shred: f: removing
-shred: f: renamed to 0
-shred: f: removed" > exp || framework_failure_
+shred: 'f': removing
+shred: 'f': renamed to '0'
+shred: 'f': removed" > exp || framework_failure_
 
 shred -v -u f 2>out || fail=1
 compare exp out || fail=1
@@ -52,29 +52,29 @@ compare exp out || fail=1
 dd bs=100K count=1 if=/dev/zero | tr '\0' 'U' > Us || framework_failure_
 printf 1 > f || framework_failure_
 echo "\
-shred: f: pass 1/20 (random)...
-shred: f: pass 2/20 (ffffff)...
-shred: f: pass 3/20 (924924)...
-shred: f: pass 4/20 (888888)...
-shred: f: pass 5/20 (db6db6)...
-shred: f: pass 6/20 (777777)...
-shred: f: pass 7/20 (492492)...
-shred: f: pass 8/20 (bbbbbb)...
-shred: f: pass 9/20 (555555)...
-shred: f: pass 10/20 (aaaaaa)...
-shred: f: pass 11/20 (random)...
-shred: f: pass 12/20 (6db6db)...
-shred: f: pass 13/20 (249249)...
-shred: f: pass 14/20 (999999)...
-shred: f: pass 15/20 (111111)...
-shred: f: pass 16/20 (000000)...
-shred: f: pass 17/20 (b6db6d)...
-shred: f: pass 18/20 (eeeeee)...
-shred: f: pass 19/20 (333333)...
-shred: f: pass 20/20 (random)...
-shred: f: removing
-shred: f: renamed to 0
-shred: f: removed" > exp || framework_failure_
+shred: 'f': pass 1/20 (random)...
+shred: 'f': pass 2/20 (ffffff)...
+shred: 'f': pass 3/20 (924924)...
+shred: 'f': pass 4/20 (888888)...
+shred: 'f': pass 5/20 (db6db6)...
+shred: 'f': pass 6/20 (777777)...
+shred: 'f': pass 7/20 (492492)...
+shred: 'f': pass 8/20 (bbbbbb)...
+shred: 'f': pass 9/20 (555555)...
+shred: 'f': pass 10/20 (aaaaaa)...
+shred: 'f': pass 11/20 (random)...
+shred: 'f': pass 12/20 (6db6db)...
+shred: 'f': pass 13/20 (249249)...
+shred: 'f': pass 14/20 (999999)...
+shred: 'f': pass 15/20 (111111)...
+shred: 'f': pass 16/20 (000000)...
+shred: 'f': pass 17/20 (b6db6d)...
+shred: 'f': pass 18/20 (eeeeee)...
+shred: 'f': pass 19/20 (333333)...
+shred: 'f': pass 20/20 (random)...
+shred: 'f': removing
+shred: 'f': renamed to '0'
+shred: 'f': removed" > exp || framework_failure_
 
 shred -v -u -n20 --random-source=Us f 2>out || fail=1
 compare exp out || fail=1
index f6a222c2c0438571e44192a305df608014886691..012d8b94e2f22f23e29d530d236d1adad63df96f 100755 (executable)
@@ -33,7 +33,7 @@ my $mb_locale = $ENV{LOCALE_FR_UTF8};
 # Normalize each diagnostic to use '-'.
 my $normalize_filename = {ERR_SUBST => 's/^$prog: .*?:/$prog: -:/'};
 
-my $no_file = "$prog: cannot read: no-file: No such file or directory\n";
+my $no_file = "$prog: cannot read: 'no-file': No such file or directory\n";
 
 my @Tests =
 (
@@ -327,7 +327,7 @@ my @Tests =
 ["o-no-file1", qw(-o no-file no-file), {EXIT=>2}, {ERR=>$no_file}],
 
 ["create-empty", qw(-o no/such/file /dev/null), {EXIT=>2},
- {ERR=>"$prog: open failed: no/such/file: No such file or directory\n"}],
+ {ERR=>"$prog: open failed: 'no/such/file': No such file or directory\n"}],
 
 # From Paul Eggert.  This was fixed in textutils-1.22k.
 ["neg-nls", '-n', {IN=>"-1\n-9\n"}, {OUT=>"-9\n-1\n"}],
index 4d04866ad51a1912a002100834d8751fa47c07df..60f22c43c177242b6c7ef5ccc825717397cb45db 100755 (executable)
@@ -27,10 +27,10 @@ my @Tests =
   (
    ['cycle-1', {IN => {f => "t b\nt s\ns t\n"}}, {OUT => "s\nt\nb\n"},
     {EXIT => 1},
-    {ERR => "tsort: f: input contains a loop:\ntsort: s\ntsort: t\n"} ],
+    {ERR => "tsort: 'f': input contains a loop:\ntsort: s\ntsort: t\n"} ],
    ['cycle-2', {IN => {f => "t x\nt s\ns t\n"}}, {OUT => "s\nt\nx\n"},
     {EXIT => 1},
-    {ERR => "tsort: f: input contains a loop:\ntsort: s\ntsort: t\n"} ],
+    {ERR => "tsort: 'f': input contains a loop:\ntsort: s\ntsort: t\n"} ],
 
    ['posix-1', {IN => "a b c c d e\ng g\nf g e f\nh h\n"},
     {OUT => "a\nc\nd\nh\nb\ne\nf\ng\n"}],
@@ -50,7 +50,7 @@ my @Tests =
    # copy of the final token were appended.
    ['odd', {IN => "a\n"},
     {EXIT => 1},
-    {ERR => "tsort: odd.1: input contains an odd number of tokens\n"}],
+    {ERR => "tsort: 'odd.1': input contains an odd number of tokens\n"}],
 
    ['only-one', {IN => {f => ""}}, {IN => {g => ""}},
     {EXIT => 1},