mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
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.
This commit is contained in:
1 parent
106d4bf159
commit
6796698c99
63 files changed
+321
-269
No files matched your search
@@ -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.
|
||||
|
||||
|
||||
@@ -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]' \
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
+1
-1
@@ -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.
|
||||
|
||||
+5
-4
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -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
|
||||
|
||||
+15
-11
@@ -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"),
|
||||
|
||||
@@ -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;
|
||||
|
||||
+3
-2
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
+3
-3
@@ -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;
|
||||
|
||||
+2
-2
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
+4
-4
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -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;
|
||||
|
||||
+4
-3
@@ -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);
|
||||
|
||||
+2
-1
@@ -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)
|
||||
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+2
-1
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+7
-6
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -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;
|
||||
}
|
||||
|
||||
+2
-1
@@ -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);
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
+5
-5
@@ -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;
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-6
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+27
-23
@@ -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)
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
|
||||
+7
-6
@@ -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 ();
|
||||
}
|
||||
|
||||
|
||||
+37
-27
@@ -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;
|
||||
|
||||
+14
-13
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
+11
-12
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -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. */
|
||||
|
||||
+3
-3
@@ -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;
|
||||
|
||||
+3
-3
@@ -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. */
|
||||
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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=>'%'}],
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
+32
-32
@@ -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
|
||||
|
||||
+2
-2
@@ -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"}],
|
||||
|
||||
+3
-3
@@ -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},
|
||||
|
||||
Reference in new issue
Block a user