diff options
author | Pádraig Brady <P@draigBrady.com> | 2015-11-01 18:53:26 +0000 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2015-11-04 23:30:14 +0000 |
commit | 08e8fd7e38f2dae7c69c54eb22d508b6517e66e5 (patch) | |
tree | 63d021e305cd93bea445f9484fe8b3446dda2c3d | |
parent | 1e8f9afac53a628dbc64e62bea53eb2da29c47fa (diff) | |
download | coreutils-08e8fd7e38f2dae7c69c54eb22d508b6517e66e5.tar.gz |
all: avoid quoting file names when possible
Quote file names using the "shell-escape" or "shell-escape-always"
methods, which quote as appropriate for most shells,
and better support copy and paste of presented names.
The "always" variant is used when the file name is
embedded in an error message with surrounding spaces.
* cfg.mk (sc_error_shell_quotes): A new syntax check rule
to suggest quotef() where appropriate.
(sc_error_shell_always_quotes): Likewise for quoteaf().
* src/system.h (quotef): A new define to apply shell quoting
when needed. I.E. when shell character or ':' is present.
(quoteaf): Likewise, but always quote.
* src/*.c: Use quotef() and quoteaf() rather than quote()
where appropriate.
* tests/: Adjust accordingly.
98 files changed, 702 insertions, 662 deletions
@@ -187,6 +187,37 @@ sc_error_quotes: exit 1; } \ || : +# Files in src/ should quote all file names in error() output +# using quotef(), to provide quoting only when necessary, +# but also provide better support for copy and paste when used. +sc_error_shell_quotes: + @cd $(srcdir)/src && \ + { GIT_PAGER= git grep -E \ + 'error \(.*%s[:"], .*(name|file)[^"]*\);$$' *.c; \ + GIT_PAGER= git grep -E \ + ' quote[ _].*file' *.c; } \ + | grep -Ev '(quotef|q[^ ]*name)' \ + && { echo '$(ME): '"Use quotef() for colon delimited names" 1>&2; \ + exit 1; } \ + || : + +# Files in src/ should quote all file names in error() output +# using quoteaf() when the name is separated with spaces, +# to distinguish the file name at issue and +# to provide better support for copy and paste. +sc_error_shell_always_quotes: + @cd $(srcdir)/src && GIT_PAGER= git grep -E \ + 'error \(.*[^:] %s[ "].*, .*(name|file)[^"]*\);$$' \ + *.c | grep -Ev '(quoteaf|q[^ ]*name)' \ + && { echo '$(ME): '"Use quoteaf() for space delimited names" 1>&2; \ + exit 1; } \ + || : + @cd $(srcdir)/src && GIT_PAGER= git grep -E -A1 \ + 'error \([^%]*[^:] %s[ "]' *.c | grep 'quotef' \ + && { echo '$(ME): '"Use quoteaf() for space delimited names" 1>&2; \ + exit 1; } \ + || : + sc_sun_os_names: @grep -nEi \ 'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \ diff --git a/gl/lib/root-dev-ino.h b/gl/lib/root-dev-ino.h index e6bf35e3c..409aef451 100644 --- a/gl/lib/root-dev-ino.h +++ b/gl/lib/root-dev-ino.h @@ -35,11 +35,11 @@ get_root_dev_ino (struct dev_ino *root_d_i); { \ if (STREQ (Dirname, "/")) \ error (0, 0, _("it is dangerous to operate recursively on %s"), \ - quote (Dirname)); \ + quoteaf (Dirname)); \ else \ error (0, 0, \ _("it is dangerous to operate recursively on %s (same as %s)"), \ - quote_n (0, Dirname), quote_n (1, "/")); \ + quoteaf_n (0, Dirname), quoteaf_n (1, "/")); \ error (0, 0, _("use --no-preserve-root to override this failsafe")); \ } \ while (0) diff --git a/src/base64.c b/src/base64.c index d5755ba5e..5ec9a9e0a 100644 --- a/src/base64.c +++ b/src/base64.c @@ -27,8 +27,8 @@ #include "system.h" #include "error.h" #include "fadvise.h" -#include "xstrtol.h" #include "quote.h" +#include "xstrtol.h" #include "xdectoint.h" #include "xfreopen.h" @@ -327,7 +327,7 @@ main (int argc, char **argv) { input_fh = fopen (infile, "rb"); if (input_fh == NULL) - error (EXIT_FAILURE, errno, "%s", quote (infile)); + error (EXIT_FAILURE, errno, "%s", quotef (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", quote (infile)); + error (EXIT_FAILURE, errno, "%s", quotef (infile)); } return EXIT_SUCCESS; @@ -37,7 +37,6 @@ #include "error.h" #include "fadvise.h" #include "full-write.h" -#include "quote.h" #include "safe-read.h" #include "xfreopen.h" @@ -169,7 +168,7 @@ simple_cat ( n_read = safe_read (input_desc, buf, bufsize); if (n_read == SAFE_READ_ERROR) { - error (0, errno, "%s", quote (infile)); + error (0, errno, "%s", quotef (infile)); return false; } @@ -325,7 +324,7 @@ cat ( else { error (0, errno, _("cannot do ioctl on %s"), - quote (infile)); + quoteaf (infile)); newlines2 = newlines; return false; } @@ -342,7 +341,7 @@ cat ( n_read = safe_read (input_desc, inbuf, insize); if (n_read == SAFE_READ_ERROR) { - error (0, errno, "%s", quote (infile)); + error (0, errno, "%s", quotef (infile)); write_pending (outbuf, &bpout); newlines2 = newlines; return false; @@ -673,7 +672,7 @@ main (int argc, char **argv) input_desc = open (infile, file_open_mode); if (input_desc < 0) { - error (0, errno, "%s", quote (infile)); + error (0, errno, "%s", quotef (infile)); ok = false; continue; } @@ -681,7 +680,7 @@ main (int argc, char **argv) if (fstat (input_desc, &stat_buf) < 0) { - error (0, errno, "%s", quote (infile)); + error (0, errno, "%s", quotef (infile)); ok = false; goto contin; } @@ -697,7 +696,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"), quote (infile)); + error (0, 0, _("%s: input file is output file"), quotef (infile)); ok = false; goto contin; } @@ -755,7 +754,7 @@ main (int argc, char **argv) contin: if (!STREQ (infile, "-") && close (input_desc) < 0) { - error (0, errno, "%s", quote (infile)); + error (0, errno, "%s", quotef (infile)); ok = false; } } diff --git a/src/chcon.c b/src/chcon.c index 4f51d70d4..4c255d0c0 100644 --- a/src/chcon.c +++ b/src/chcon.c @@ -153,7 +153,7 @@ change_file_context (int fd, char const *file) if (status < 0 && errno != ENODATA) { error (0, errno, _("failed to get security context of %s"), - quote (file)); + quoteaf (file)); return 1; } @@ -163,7 +163,7 @@ change_file_context (int fd, char const *file) if (file_context == NULL) { error (0, 0, _("can't apply partial context to unlabeled file %s"), - quote (file)); + quoteaf (file)); return 1; } @@ -187,7 +187,7 @@ change_file_context (int fd, char const *file) { errors = 1; error (0, errno, _("failed to change context of %s to %s"), - quote_n (0, file), quote_n (1, context_string)); + quoteaf_n (0, file), quote_n (1, context_string)); } } @@ -251,18 +251,19 @@ process_file (FTS *fts, FTSENT *ent) fts_set (fts, ent, FTS_AGAIN); return true; } - error (0, ent->fts_errno, _("cannot access %s"), quote (file_full_name)); + error (0, ent->fts_errno, _("cannot access %s"), + quoteaf (file_full_name)); ok = false; break; case FTS_ERR: - error (0, ent->fts_errno, "%s", quote (file_full_name)); + error (0, ent->fts_errno, "%s", quotef (file_full_name)); ok = false; break; case FTS_DNR: error (0, ent->fts_errno, _("cannot read directory %s"), - quote (file_full_name)); + quoteaf (file_full_name)); ok = false; break; @@ -289,7 +290,7 @@ process_file (FTS *fts, FTSENT *ent) { if (verbose) printf (_("changing security context of %s\n"), - quote (file_full_name)); + quoteaf (file_full_name)); if (change_file_context (fts->fts_cwd_fd, file) != 0) ok = false; @@ -543,7 +544,7 @@ main (int argc, char **argv) if (getfilecon (reference_file, &ref_context) < 0) error (EXIT_FAILURE, errno, _("failed to get security context of %s"), - quote (reference_file)); + quoteaf (reference_file)); specified_context = ref_context; } @@ -572,7 +573,7 @@ main (int argc, char **argv) root_dev_ino = get_root_dev_ino (&dev_ino_buf); if (root_dev_ino == NULL) error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote ("/")); + quoteaf ("/")); } else { diff --git a/src/chgrp.c b/src/chgrp.c index eb1887e60..c07270cc9 100644 --- a/src/chgrp.c +++ b/src/chgrp.c @@ -89,7 +89,8 @@ parse_group (const char *name) unsigned long int tmp; if (! (xstrtoul (name, NULL, 10, &tmp, "") == LONGINT_OK && tmp <= GID_T_MAX)) - error (EXIT_FAILURE, 0, _("invalid group: %s"), quote (name)); + error (EXIT_FAILURE, 0, _("invalid group: %s"), + quote (name)); gid = tmp; } endgrent (); /* Save a file descriptor. */ @@ -285,7 +286,7 @@ main (int argc, char **argv) struct stat ref_stats; if (stat (reference_file, &ref_stats)) error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote (reference_file)); + quoteaf (reference_file)); gid = ref_stats.st_gid; chopt.group_name = gid_to_name (ref_stats.st_gid); @@ -303,7 +304,7 @@ main (int argc, char **argv) chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf); if (chopt.root_dev_ino == NULL) error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote ("/")); + quoteaf ("/")); } bit_flags |= FTS_DEFER_STAT; diff --git a/src/chmod.c b/src/chmod.c index 988ba7269..4c952b363 100644 --- a/src/chmod.c +++ b/src/chmod.c @@ -124,7 +124,7 @@ mode_changed (int dir_fd, char const *file, char const *file_full_name, { if (! force_silent) error (0, errno, _("getting new attributes of %s"), - quote (file_full_name)); + quoteaf (file_full_name)); return false; } @@ -148,7 +148,7 @@ describe_change (const char *file, mode_t old_mode, mode_t mode, if (changed == CH_NOT_APPLIED) { printf (_("neither symbolic link %s nor referent has been changed\n"), - quote (file)); + quoteaf (file)); return; } @@ -168,13 +168,13 @@ describe_change (const char *file, mode_t old_mode, mode_t mode, break; case CH_NO_CHANGE_REQUESTED: fmt = _("mode of %s retained as %04lo (%s)\n"); - printf (fmt, quote (file), + printf (fmt, quoteaf (file), (unsigned long int) (mode & CHMOD_MODE_BITS), &perms[1]); return; default: abort (); } - printf (fmt, quote (file), + printf (fmt, quoteaf (file), (unsigned long int) (old_mode & CHMOD_MODE_BITS), &old_perms[1], (unsigned long int) (mode & CHMOD_MODE_BITS), &perms[1]); } @@ -215,27 +215,27 @@ process_file (FTS *fts, FTSENT *ent) } if (! force_silent) error (0, ent->fts_errno, _("cannot access %s"), - quote (file_full_name)); + quoteaf (file_full_name)); ok = false; break; case FTS_ERR: if (! force_silent) - error (0, ent->fts_errno, "%s", quote (file_full_name)); + error (0, ent->fts_errno, "%s", quotef (file_full_name)); ok = false; break; case FTS_DNR: if (! force_silent) error (0, ent->fts_errno, _("cannot read directory %s"), - quote (file_full_name)); + quoteaf (file_full_name)); ok = false; break; case FTS_SLNONE: if (! force_silent) error (0, 0, _("cannot operate on dangling symlink %s"), - quote (file_full_name)); + quoteaf (file_full_name)); ok = false; break; @@ -275,7 +275,7 @@ process_file (FTS *fts, FTSENT *ent) { if (! force_silent) error (0, errno, _("changing permissions of %s"), - quote (file_full_name)); + quoteaf (file_full_name)); ok = false; } } @@ -311,7 +311,7 @@ process_file (FTS *fts, FTSENT *ent) new_perms[10] = naively_expected_perms[10] = '\0'; error (0, 0, _("%s: new permissions are %s, not %s"), - quote (file_full_name), + quotef (file_full_name), new_perms + 1, naively_expected_perms + 1); ok = false; } @@ -536,7 +536,7 @@ main (int argc, char **argv) change = mode_create_from_ref (reference_file); if (!change) error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote (reference_file)); + quoteaf (reference_file)); } else { @@ -555,7 +555,7 @@ main (int argc, char **argv) root_dev_ino = get_root_dev_ino (&dev_ino_buf); if (root_dev_ino == NULL) error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote ("/")); + quoteaf ("/")); } else { diff --git a/src/chown-core.c b/src/chown-core.c index e8a7d5289..0e5114606 100644 --- a/src/chown-core.c +++ b/src/chown-core.c @@ -26,7 +26,6 @@ #include "chown-core.h" #include "error.h" #include "ignore-value.h" -#include "quote.h" #include "root-dev-ino.h" #include "xfts.h" @@ -145,7 +144,7 @@ describe_change (const char *file, enum Change_status changed, if (changed == CH_NOT_APPLIED) { printf (_("neither symbolic link %s nor referent has been changed\n"), - quote (file)); + quoteaf (file)); return; } @@ -185,7 +184,7 @@ describe_change (const char *file, enum Change_status changed, abort (); } - printf (fmt, quote (file), old_spec, spec); + printf (fmt, quoteaf (file), old_spec, spec); free (old_spec); free (spec); @@ -323,20 +322,20 @@ change_file_owner (FTS *fts, FTSENT *ent, } if (! chopt->force_silent) error (0, ent->fts_errno, _("cannot access %s"), - quote (file_full_name)); + quoteaf (file_full_name)); ok = false; break; case FTS_ERR: if (! chopt->force_silent) - error (0, ent->fts_errno, "%s", quote (file_full_name)); + error (0, ent->fts_errno, "%s", quotef (file_full_name)); ok = false; break; case FTS_DNR: if (! chopt->force_silent) error (0, ent->fts_errno, _("cannot read directory %s"), - quote (file_full_name)); + quoteaf (file_full_name)); ok = false; break; @@ -377,7 +376,7 @@ change_file_owner (FTS *fts, FTSENT *ent, { if (! chopt->force_silent) error (0, errno, _("cannot dereference %s"), - quote (file_full_name)); + quoteaf (file_full_name)); ok = false; } @@ -466,7 +465,7 @@ change_file_owner (FTS *fts, FTSENT *ent, error (0, errno, (uid != (uid_t) -1 ? _("changing ownership of %s") : _("changing group of %s")), - quote (file_full_name)); + quoteaf (file_full_name)); } if (chopt->verbosity != V_off) diff --git a/src/chown.c b/src/chown.c index ba1814b41..79606e68b 100644 --- a/src/chown.c +++ b/src/chown.c @@ -287,7 +287,7 @@ main (int argc, char **argv) struct stat ref_stats; if (stat (reference_file, &ref_stats)) error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote (reference_file)); + quoteaf (reference_file)); uid = ref_stats.st_uid; gid = ref_stats.st_gid; @@ -316,7 +316,7 @@ main (int argc, char **argv) chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf); if (chopt.root_dev_ino == NULL) error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote ("/")); + quoteaf ("/")); } bit_flags |= FTS_DEFER_STAT; diff --git a/src/chroot.c b/src/chroot.c index 9551d934f..ec2f5c444 100644 --- a/src/chroot.c +++ b/src/chroot.c @@ -200,7 +200,7 @@ Run COMMAND with root directory set to NEWROOT.\n\ "), stdout); printf (_("\ --skip-chdir do not change working directory to %s\n\ -"), quote ("/")); +"), quoteaf ("/")); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); @@ -284,7 +284,7 @@ main (int argc, char **argv) if (! is_oldroot && skip_chdir) { error (0, 0, _("option --skip-chdir only permitted if NEWROOT is old %s"), - quote ("/")); + quoteaf ("/")); usage (EXIT_CANCELED); } @@ -327,7 +327,7 @@ main (int argc, char **argv) if (chroot (newroot) != 0) error (EXIT_CANCELED, errno, _("cannot change root directory to %s"), - quote (newroot)); + quoteaf (newroot)); if (! skip_chdir && chdir ("/")) error (EXIT_CANCELED, errno, _("cannot chdir to root directory")); diff --git a/src/cksum.c b/src/cksum.c index 2a19c678a..ef51010b2 100644 --- a/src/cksum.c +++ b/src/cksum.c @@ -44,7 +44,6 @@ #include <stdint.h> #include "system.h" #include "fadvise.h" -#include "quote.h" #include "xfreopen.h" #ifdef CRCTAB @@ -202,7 +201,7 @@ cksum (const char *file, bool print_name) fp = fopen (file, (O_BINARY ? "rb" : "r")); if (fp == NULL) { - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); return false; } } @@ -214,7 +213,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"), quote (file)); + error (EXIT_FAILURE, 0, _("%s: file too long"), quotef (file)); length += bytes_read; while (bytes_read--) crc = (crc << 8) ^ crctab[((crc >> 24) ^ *cp++) & 0xFF]; @@ -224,7 +223,7 @@ cksum (const char *file, bool print_name) if (ferror (fp)) { - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); if (!STREQ (file, "-")) fclose (fp); return false; @@ -232,7 +231,7 @@ cksum (const char *file, bool print_name) if (!STREQ (file, "-") && fclose (fp) == EOF) { - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); return false; } diff --git a/src/comm.c b/src/comm.c index a6fbde196..d4c9f24df 100644 --- a/src/comm.c +++ b/src/comm.c @@ -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", quote (infiles[i])); + error (EXIT_FAILURE, errno, "%s", quotef (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", quote (infiles[i])); + error (EXIT_FAILURE, errno, "%s", quotef (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", quote (infiles[i])); + error (EXIT_FAILURE, errno, "%s", quotef (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", quote (infiles[i])); + error (EXIT_FAILURE, errno, "%s", quotef (infiles[i])); } int diff --git a/src/copy.c b/src/copy.c index edf022ef1..dc1cd2904 100644 --- a/src/copy.c +++ b/src/copy.c @@ -178,7 +178,7 @@ create_hole (int fd, char const *name, bool punch_holes, off_t size) if (file_end < 0) { - error (0, errno, _("cannot lseek %s"), quote (name)); + error (0, errno, _("cannot lseek %s"), quoteaf (name)); return false; } @@ -188,7 +188,7 @@ create_hole (int fd, char const *name, bool punch_holes, off_t size) then make this allocation permanent. */ if (punch_holes && punch_hole (fd, file_end - size, size) < 0) { - error (0, errno, _("error deallocating %s"), quote (name)); + error (0, errno, _("error deallocating %s"), quoteaf (name)); return false; } @@ -226,7 +226,7 @@ sparse_copy (int src_fd, int dest_fd, char *buf, size_t buf_size, { if (errno == EINTR) continue; - error (0, errno, _("error reading %s"), quote (src_name)); + error (0, errno, _("error reading %s"), quoteaf (src_name)); return false; } if (n_read == 0) @@ -259,7 +259,8 @@ sparse_copy (int src_fd, int dest_fd, char *buf, size_t buf_size, { if (full_write (dest_fd, pbuf, psize) != psize) { - error (0, errno, _("error writing %s"), quote (dst_name)); + error (0, errno, _("error writing %s"), + quoteaf (dst_name)); return false; } } @@ -289,7 +290,7 @@ sparse_copy (int src_fd, int dest_fd, char *buf, size_t buf_size, psize += csize; else { - error (0, 0, _("overflow reading %s"), quote (src_name)); + error (0, 0, _("overflow reading %s"), quoteaf (src_name)); return false; } } @@ -407,7 +408,7 @@ extent_copy (int src_fd, int dest_fd, char *buf, size_t buf_size, } error (0, errno, _("%s: failed to get extents info"), - quote (src_name)); + quotef (src_name)); return false; } @@ -439,7 +440,7 @@ extent_copy (int src_fd, int dest_fd, char *buf, size_t buf_size, { if (lseek (src_fd, ext_start, SEEK_SET) < 0) { - error (0, errno, _("cannot lseek %s"), quote (src_name)); + error (0, errno, _("cannot lseek %s"), quoteaf (src_name)); fail: extent_scan_free (&scan); return false; @@ -465,7 +466,8 @@ extent_copy (int src_fd, int dest_fd, char *buf, size_t buf_size, if (! write_zeros (dest_fd, nzeros)) { - error (0, errno, _("%s: write failed"), quote (dst_name)); + error (0, errno, _("%s: write failed"), + quotef (dst_name)); goto fail; } @@ -534,14 +536,14 @@ extent_copy (int src_fd, int dest_fd, char *buf, size_t buf_size, ? ftruncate (dest_fd, src_total_size) : ! write_zeros (dest_fd, src_total_size - dest_pos))) { - error (0, errno, _("failed to extend %s"), quote (dst_name)); + error (0, errno, _("failed to extend %s"), quoteaf (dst_name)); return false; } if (sparse_mode == SPARSE_ALWAYS && dest_pos < src_total_size && punch_hole (dest_fd, dest_pos, src_total_size - dest_pos) < 0) { - error (0, errno, _("error deallocating %s"), quote (dst_name)); + error (0, errno, _("error deallocating %s"), quoteaf (dst_name)); return false; } @@ -604,7 +606,7 @@ copy_attr_allerror (struct error_context *ctx _GL_UNUSED, static char const * copy_attr_quote (struct error_context *ctx _GL_UNUSED, char const *str) { - return quote (str); + return quoteaf (str); } static void @@ -695,7 +697,7 @@ copy_dir (char const *src_name_in, char const *dst_name_in, bool new_dst, { /* This diagnostic is a bit vague because savedir can fail in several different ways. */ - error (0, errno, _("cannot access %s"), quote (src_name_in)); + error (0, errno, _("cannot access %s"), quoteaf (src_name_in)); return false; } @@ -777,7 +779,7 @@ set_owner (const struct cp_options *x, char const *dst_name, int dest_desc, { if (! owner_failure_ok (x)) error (0, errno, _("clearing permissions for %s"), - quote (dst_name)); + quoteaf (dst_name)); return -x->require_preserve; } } @@ -812,7 +814,7 @@ set_owner (const struct cp_options *x, char const *dst_name, int dest_desc, if (! chown_failure_ok (x)) { error (0, errno, _("failed to preserve ownership for %s"), - quote (dst_name)); + quoteaf (dst_name)); if (x->require_preserve) return -1; } @@ -837,13 +839,13 @@ set_author (const char *dst_name, int dest_desc, const struct stat *src_sb) ? file_name_lookup (dst_name, 0, 0) : getdport (dest_desc)); if (file == MACH_PORT_NULL) - error (0, errno, _("failed to lookup file %s"), quote (dst_name)); + error (0, errno, _("failed to lookup file %s"), quoteaf (dst_name)); else { error_t err = file_chauthor (file, src_sb->st_author); if (err) error (0, err, _("failed to preserve authorship for %s"), - quote (dst_name)); + quoteaf (dst_name)); mach_port_deallocate (mach_task_self (), file); } #else @@ -895,7 +897,7 @@ set_process_security_ctx (char const *src_name, char const *dst_name, { error (0, errno, _("failed to get security context of %s"), - quote (src_name)); + quoteaf (src_name)); } if (x->require_preserve_context) return false; @@ -910,7 +912,7 @@ set_process_security_ctx (char const *src_name, char const *dst_name, { error (0, errno, _("failed to set default file creation context for %s"), - quote (dst_name)); + quoteaf (dst_name)); } } @@ -936,7 +938,7 @@ set_file_security_ctx (char const *dst_name, bool process_local, { if (all_errors || (some_errors && !errno_unsupported (errno))) error (0, errno, _("failed to set the security context of %s"), - quote_n (0, dst_name)); + quoteaf_n (0, dst_name)); return false; } @@ -1008,13 +1010,13 @@ copy_reg (char const *src_name, char const *dst_name, | (x->dereference == DEREF_NEVER ? O_NOFOLLOW : 0))); if (source_desc < 0) { - error (0, errno, _("cannot open %s for reading"), quote (src_name)); + error (0, errno, _("cannot open %s for reading"), quoteaf (src_name)); return false; } if (fstat (source_desc, &src_open_sb) != 0) { - error (0, errno, _("cannot fstat %s"), quote (src_name)); + error (0, errno, _("cannot fstat %s"), quoteaf (src_name)); return_val = false; goto close_src_desc; } @@ -1025,7 +1027,7 @@ copy_reg (char const *src_name, char const *dst_name, { error (0, 0, _("skipping file %s, as it was replaced while being copied"), - quote (src_name)); + quoteaf (src_name)); return_val = false; goto close_src_desc; } @@ -1064,12 +1066,12 @@ copy_reg (char const *src_name, char const *dst_name, { if (unlink (dst_name) != 0) { - error (0, errno, _("cannot remove %s"), quote (dst_name)); + error (0, errno, _("cannot remove %s"), quoteaf (dst_name)); return_val = false; goto close_src_desc; } if (x->verbose) - printf (_("removed %s\n"), quote (dst_name)); + printf (_("removed %s\n"), quoteaf (dst_name)); /* Tell caller that the destination file was unlinked. */ *new_dst = true; @@ -1122,7 +1124,7 @@ copy_reg (char const *src_name, char const *dst_name, else { error (0, 0, _("not writing through dangling symlink %s"), - quote (dst_name)); + quoteaf (dst_name)); return_val = false; goto close_src_desc; } @@ -1160,14 +1162,14 @@ copy_reg (char const *src_name, char const *dst_name, /* Otherwise, it's an error. */ error (0, dest_errno, _("cannot create regular file %s"), - quote (dst_name)); + quoteaf (dst_name)); return_val = false; goto close_src_desc; } if (fstat (dest_desc, &sb) != 0) { - error (0, errno, _("cannot fstat %s"), quote (dst_name)); + error (0, errno, _("cannot fstat %s"), quoteaf (dst_name)); return_val = false; goto close_src_and_dst_desc; } @@ -1181,7 +1183,7 @@ copy_reg (char const *src_name, char const *dst_name, if (!clone_ok) { error (0, errno, _("failed to clone %s from %s"), - quote_n (0, dst_name), quote_n (1, src_name)); + quoteaf_n (0, dst_name), quoteaf_n (1, src_name)); return_val = false; goto close_src_and_dst_desc; } @@ -1278,7 +1280,7 @@ copy_reg (char const *src_name, char const *dst_name, } else if (wrote_hole_at_eof && ftruncate (dest_desc, n_read) < 0) { - error (0, errno, _("failed to extend %s"), quote (dst_name)); + error (0, errno, _("failed to extend %s"), quoteaf (dst_name)); return_val = false; goto close_src_and_dst_desc; } @@ -1293,7 +1295,7 @@ preserve_metadata: if (fdutimens (dest_desc, dst_name, timespec) != 0) { - error (0, errno, _("preserving times for %s"), quote (dst_name)); + error (0, errno, _("preserving times for %s"), quoteaf (dst_name)); if (x->require_preserve) { return_val = false; @@ -1361,7 +1363,7 @@ preserve_metadata: && fchmod_or_lchmod (dest_desc, dst_name, dst_mode) != 0) { error (0, errno, _("preserving permissions for %s"), - quote (dst_name)); + quoteaf (dst_name)); if (x->require_preserve) return_val = false; } @@ -1370,13 +1372,13 @@ preserve_metadata: close_src_and_dst_desc: if (close (dest_desc) < 0) { - error (0, errno, _("failed to close %s"), quote (dst_name)); + error (0, errno, _("failed to close %s"), quoteaf (dst_name)); return_val = false; } close_src_desc: if (close (source_desc) < 0) { - error (0, errno, _("failed to close %s"), quote (src_name)); + error (0, errno, _("failed to close %s"), quoteaf (src_name)); return_val = false; } @@ -1654,14 +1656,14 @@ overwrite_ok (struct cp_options const *x, char const *dst_name, || x->unlink_dest_after_failed_open) ? _("%s: replace %s, overriding mode %04lo (%s)? ") : _("%s: unwritable %s (mode %04lo, %s); try anyway? "), - program_name, quote (dst_name), + program_name, quoteaf (dst_name), (unsigned long int) (dst_sb->st_mode & CHMOD_MODE_BITS), &perms[1]); } else { fprintf (stderr, _("%s: overwrite %s? "), - program_name, quote (dst_name)); + program_name, quoteaf (dst_name)); } return yesno (); @@ -1728,9 +1730,9 @@ abandon_move (const struct cp_options *x, static void emit_verbose (char const *src, char const *dst, char const *backup_dst_name) { - printf ("%s -> %s", quote_n (0, src), quote_n (1, dst)); + printf ("%s -> %s", quoteaf_n (0, src), quoteaf_n (1, dst)); if (backup_dst_name) - printf (_(" (backup: %s)"), quote (backup_dst_name)); + printf (_(" (backup: %s)"), quoteaf (backup_dst_name)); putchar ('\n'); } @@ -1767,11 +1769,11 @@ create_hard_link (char const *src_name, char const *dst_name, { if (unlink (dst_name) != 0) { - error (0, errno, _("cannot remove %s"), quote (dst_name)); + error (0, errno, _("cannot remove %s"), quoteaf (dst_name)); return false; } if (verbose) - printf (_("removed %s\n"), quote (dst_name)); + printf (_("removed %s\n"), quoteaf (dst_name)); link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, flags) != 0); } @@ -1779,7 +1781,7 @@ create_hard_link (char const *src_name, char const *dst_name, if (link_failed) { error (0, errno, _("cannot create hard link %s to %s"), - quote_n (0, dst_name), quote_n (1, src_name)); + quoteaf_n (0, dst_name), quoteaf_n (1, src_name)); return false; } @@ -1841,7 +1843,7 @@ copy_internal (char const *src_name, char const *dst_name, if (XSTAT (x, src_name, &src_sb) != 0) { - error (0, errno, _("cannot stat %s"), quote (src_name)); + error (0, errno, _("cannot stat %s"), quoteaf (src_name)); return false; } @@ -1849,7 +1851,7 @@ copy_internal (char const *src_name, char const *dst_name, if (S_ISDIR (src_mode) && !x->recursive) { - error (0, 0, _("omitting directory %s"), quote (src_name)); + error (0, 0, _("omitting directory %s"), quoteaf (src_name)); return false; } @@ -1864,7 +1866,7 @@ copy_internal (char const *src_name, char const *dst_name, && seen_file (x->src_info, src_name, &src_sb)) { error (0, 0, _("warning: source file %s specified more than once"), - quote (src_name)); + quoteaf (src_name)); return true; } @@ -1895,7 +1897,7 @@ copy_internal (char const *src_name, char const *dst_name, { if (errno != ENOENT) { - error (0, errno, _("cannot stat %s"), quote (dst_name)); + error (0, errno, _("cannot stat %s"), quoteaf (dst_name)); return false; } else @@ -1913,7 +1915,7 @@ copy_internal (char const *src_name, char const *dst_name, x, &return_now)) { error (0, 0, _("%s and %s are the same file"), - quote_n (0, src_name), quote_n (1, dst_name)); + quoteaf_n (0, src_name), quoteaf_n (1, dst_name)); return false; } @@ -2003,7 +2005,7 @@ copy_internal (char const *src_name, char const *dst_name, { error (0, 0, _("cannot overwrite non-directory %s with directory %s"), - quote_n (0, dst_name), quote_n (1, src_name)); + quoteaf_n (0, dst_name), quoteaf_n (1, src_name)); return false; } } @@ -2021,7 +2023,7 @@ copy_internal (char const *src_name, char const *dst_name, { error (0, 0, _("will not overwrite just-created %s with %s"), - quote_n (0, dst_name), quote_n (1, src_name)); + quoteaf_n (0, dst_name), quoteaf_n (1, src_name)); return false; } } @@ -2039,7 +2041,7 @@ copy_internal (char const *src_name, char const *dst_name, { error (0, 0, _("cannot overwrite directory %s with non-directory"), - quote (dst_name)); + quoteaf (dst_name)); return false; } } @@ -2053,7 +2055,7 @@ copy_internal (char const *src_name, char const *dst_name, { error (0, 0, _("cannot move directory onto non-directory: %s -> %s"), - quote_n (0, src_name), quote_n (0, dst_name)); + quotef_n (0, src_name), quotef_n (0, dst_name)); return false; } } @@ -2085,8 +2087,8 @@ copy_internal (char const *src_name, char const *dst_name, ? _("backing up %s would destroy source; %s not moved") : _("backing up %s would destroy source; %s not copied")); error (0, 0, fmt, - quote_n (0, dst_name), - quote_n (1, src_name)); + quoteaf_n (0, dst_name), + quoteaf_n (1, src_name)); free (tmp_backup); return false; } @@ -2106,7 +2108,8 @@ copy_internal (char const *src_name, char const *dst_name, { if (errno != ENOENT) { - error (0, errno, _("cannot backup %s"), quote (dst_name)); + error (0, errno, _("cannot backup %s"), + quoteaf (dst_name)); return false; } else @@ -2131,12 +2134,12 @@ copy_internal (char const *src_name, char const *dst_name, { if (unlink (dst_name) != 0 && errno != ENOENT) { - error (0, errno, _("cannot remove %s"), quote (dst_name)); + error (0, errno, _("cannot remove %s"), quoteaf (dst_name)); return false; } new_dst = true; if (x->verbose) - printf (_("removed %s\n"), quote (dst_name)); + printf (_("removed %s\n"), quoteaf (dst_name)); } } } @@ -2171,7 +2174,7 @@ copy_internal (char const *src_name, char const *dst_name, { error (0, 0, _("will not copy %s through just-created symlink %s"), - quote_n (0, src_name), quote_n (1, dst_name)); + quoteaf_n (0, src_name), quoteaf_n (1, dst_name)); return false; } } @@ -2248,8 +2251,8 @@ copy_internal (char const *src_name, char const *dst_name, if (same_name (src_name, earlier_file)) { error (0, 0, _("cannot copy a directory, %s, into itself, %s"), - quote_n (0, top_level_src_name), - quote_n (1, top_level_dst_name)); + quoteaf_n (0, top_level_src_name), + quoteaf_n (1, top_level_dst_name)); *copy_into_self = true; goto un_backup; } @@ -2257,7 +2260,7 @@ copy_internal (char const *src_name, char const *dst_name, { error (0, 0, _("warning: source directory %s " "specified more than once"), - quote (top_level_src_name)); + quoteaf (top_level_src_name)); /* We only do backups in move mode and for non dirs, and in move mode this won't be the issue as the source will be missing for subsequent attempts. @@ -2278,7 +2281,7 @@ copy_internal (char const *src_name, char const *dst_name, else { error (0, 0, _("will not create hard link %s to directory %s"), - quote_n (0, dst_name), quote_n (1, earlier_file)); + quoteaf_n (0, dst_name), quoteaf_n (1, earlier_file)); goto un_backup; } } @@ -2335,8 +2338,8 @@ copy_internal (char const *src_name, char const *dst_name, failing with a specific errno value. Expect problems on non-POSIX systems. */ error (0, 0, _("cannot move %s to a subdirectory of itself, %s"), - quote_n (0, top_level_src_name), - quote_n (1, top_level_dst_name)); + quoteaf_n (0, top_level_src_name), + quoteaf_n (1, top_level_dst_name)); /* Note that there is no need to call forget_created here, (compare with the other calls in this file) since the @@ -2378,7 +2381,7 @@ copy_internal (char const *src_name, char const *dst_name, fail. Etc. */ error (0, errno, _("cannot move %s to %s"), - quote_n (0, src_name), quote_n (1, dst_name)); + quoteaf_n (0, src_name), quoteaf_n (1, dst_name)); forget_created (src_sb.st_ino, src_sb.st_dev); return false; } @@ -2394,7 +2397,7 @@ copy_internal (char const *src_name, char const *dst_name, { error (0, errno, _("inter-device move failed: %s to %s; unable to remove target"), - quote_n (0, src_name), quote_n (1, dst_name)); + quoteaf_n (0, src_name), quoteaf_n (1, dst_name)); forget_created (src_sb.st_ino, src_sb.st_dev); return false; } @@ -2434,7 +2437,7 @@ copy_internal (char const *src_name, char const *dst_name, if (is_ancestor (&src_sb, ancestors)) { error (0, 0, _("cannot copy cyclic symbolic link %s"), - quote (src_name)); + quoteaf (src_name)); goto un_backup; } @@ -2454,7 +2457,7 @@ copy_internal (char const *src_name, char const *dst_name, if (mkdir (dst_name, dst_mode_bits & ~omitted_permissions) != 0) { error (0, errno, _("cannot create directory %s"), - quote (dst_name)); + quoteaf (dst_name)); goto un_backup; } @@ -2464,7 +2467,7 @@ copy_internal (char const *src_name, char const *dst_name, if (lstat (dst_name, &dst_sb) != 0) { - error (0, errno, _("cannot stat %s"), quote (dst_name)); + error (0, errno, _("cannot stat %s"), quoteaf (dst_name)); goto un_backup; } else if ((dst_sb.st_mode & S_IRWXU) != S_IRWXU) @@ -2477,7 +2480,7 @@ copy_internal (char const *src_name, char const *dst_name, if (lchmod (dst_name, dst_mode | S_IRWXU) != 0) { error (0, errno, _("setting permissions for %s"), - quote (dst_name)); + quoteaf (dst_name)); goto un_backup; } } @@ -2554,14 +2557,14 @@ copy_internal (char const *src_name, char const *dst_name, { error (0, 0, _("%s: can make relative symbolic links only in current directory"), - quote (dst_name)); + quotef (dst_name)); goto un_backup; } } if (symlink (src_name, dst_name) != 0) { error (0, errno, _("cannot create symbolic link %s to %s"), - quote_n (0, dst_name), quote_n (1, src_name)); + quoteaf_n (0, dst_name), quoteaf_n (1, src_name)); goto un_backup; } } @@ -2612,7 +2615,7 @@ copy_internal (char const *src_name, char const *dst_name, if (mknod (dst_name, src_mode & ~omitted_permissions, 0) != 0) if (mkfifo (dst_name, src_mode & ~S_IFIFO & ~omitted_permissions) != 0) { - error (0, errno, _("cannot create fifo %s"), quote (dst_name)); + error (0, errno, _("cannot create fifo %s"), quoteaf (dst_name)); goto un_backup; } } @@ -2622,7 +2625,7 @@ copy_internal (char const *src_name, char const *dst_name, != 0) { error (0, errno, _("cannot create special file %s"), - quote (dst_name)); + quoteaf (dst_name)); goto un_backup; } } @@ -2632,7 +2635,8 @@ copy_internal (char const *src_name, char const *dst_name, dest_is_symlink = true; if (src_link_val == NULL) { - error (0, errno, _("cannot read symbolic link %s"), quote (src_name)); + error (0, errno, _("cannot read symbolic link %s"), + quoteaf (src_name)); goto un_backup; } @@ -2660,7 +2664,7 @@ copy_internal (char const *src_name, char const *dst_name, if (! same_link) { error (0, saved_errno, _("cannot create symbolic link %s"), - quote (dst_name)); + quoteaf (dst_name)); goto un_backup; } } @@ -2691,7 +2695,7 @@ copy_internal (char const *src_name, char const *dst_name, } else { - error (0, 0, _("%s has unknown file type"), quote (src_name)); + error (0, 0, _("%s has unknown file type"), quoteaf (src_name)); goto un_backup; } @@ -2750,7 +2754,7 @@ copy_internal (char const *src_name, char const *dst_name, : utimens (dst_name, timespec)) != 0) { - error (0, errno, _("preserving times for %s"), quote (dst_name)); + error (0, errno, _("preserving times for %s"), quoteaf (dst_name)); if (x->require_preserve) return false; } @@ -2814,7 +2818,7 @@ copy_internal (char const *src_name, char const *dst_name, rules for special mode bits. */ if (new_dst && lstat (dst_name, &dst_sb) != 0) { - error (0, errno, _("cannot stat %s"), quote (dst_name)); + error (0, errno, _("cannot stat %s"), quoteaf (dst_name)); return false; } dst_mode = dst_sb.st_mode; @@ -2828,7 +2832,7 @@ copy_internal (char const *src_name, char const *dst_name, if (lchmod (dst_name, dst_mode | omitted_permissions) != 0) { error (0, errno, _("preserving permissions for %s"), - quote (dst_name)); + quoteaf (dst_name)); if (x->require_preserve) return false; } @@ -2854,12 +2858,12 @@ un_backup: if (dst_backup) { if (rename (dst_backup, dst_name) != 0) - error (0, errno, _("cannot un-backup %s"), quote (dst_name)); + error (0, errno, _("cannot un-backup %s"), quoteaf (dst_name)); else { if (x->verbose) printf (_("%s -> %s (unbackup)\n"), - quote_n (0, dst_backup), quote_n (1, dst_name)); + quoteaf_n (0, dst_backup), quoteaf_n (1, dst_name)); } } return false; diff --git a/src/coreutils.c b/src/coreutils.c index 7f868347d..4141346b3 100644 --- a/src/coreutils.c +++ b/src/coreutils.c @@ -174,7 +174,8 @@ main (int argc, char **argv) { argv[nskip] = arg_name; /* XXX: Discards any specified path. */ launch_program (prog_name, argc - nskip, argv + nskip); - error (EXIT_FAILURE, 0, _("unknown program %s"), quote (prog_name)); + error (EXIT_FAILURE, 0, _("unknown program %s"), + quote (prog_name)); } } @@ -198,7 +199,8 @@ main (int argc, char **argv) /* Only print the error message when no options have been passed to coreutils. */ if (optind == 1 && prog_name && !STREQ (prog_name, "coreutils")) - error (0, 0, _("unknown program %s"), quote (prog_name)); + error (0, 0, _("unknown program %s"), + quote (prog_name)); usage (EXIT_FAILURE); } @@ -322,7 +322,7 @@ re_protect (char const *const_dst_name, size_t src_offset, if (utimens (dst_name, timespec)) { error (0, errno, _("failed to preserve times for %s"), - quote (dst_name)); + quoteaf (dst_name)); return false; } } @@ -334,7 +334,7 @@ re_protect (char const *const_dst_name, size_t src_offset, if (! chown_failure_ok (x)) { error (0, errno, _("failed to preserve ownership for %s"), - quote (dst_name)); + quoteaf (dst_name)); return false; } /* Failing to preserve ownership is OK. Still, try to preserve @@ -353,7 +353,7 @@ re_protect (char const *const_dst_name, size_t src_offset, if (lchmod (dst_name, p->st.st_mode) != 0) { error (0, errno, _("failed to preserve permissions for %s"), - quote (dst_name)); + quoteaf (dst_name)); return false; } } @@ -436,7 +436,7 @@ make_dir_parents_private (char const *const_dir, size_t src_offset, if (src_errno) { error (0, src_errno, _("failed to get attributes of %s"), - quote (src)); + quoteaf (src)); return false; } @@ -480,7 +480,7 @@ make_dir_parents_private (char const *const_dir, size_t src_offset, if (mkdir (dir, mkdir_mode) != 0) { error (0, errno, _("cannot make directory %s"), - quote (dir)); + quoteaf (dir)); return false; } else @@ -496,7 +496,7 @@ make_dir_parents_private (char const *const_dir, size_t src_offset, if (lstat (dir, &stats)) { error (0, errno, _("failed to get attributes of %s"), - quote (dir)); + quoteaf (dir)); return false; } @@ -521,7 +521,7 @@ make_dir_parents_private (char const *const_dir, size_t src_offset, if (lchmod (dir, stats.st_mode | S_IRWXU) != 0) { error (0, errno, _("setting permissions for %s"), - quote (dir)); + quoteaf (dir)); return false; } } @@ -529,7 +529,7 @@ make_dir_parents_private (char const *const_dir, size_t src_offset, else if (!S_ISDIR (stats.st_mode)) { error (0, 0, _("%s exists but is not a directory"), - quote (dir)); + quoteaf (dir)); return false; } else @@ -547,7 +547,7 @@ make_dir_parents_private (char const *const_dir, size_t src_offset, else if (!S_ISDIR (stats.st_mode)) { - error (0, 0, _("%s exists but is not a directory"), quote (dst_dir)); + error (0, 0, _("%s exists but is not a directory"), quoteaf (dst_dir)); return false; } else @@ -574,7 +574,7 @@ target_directory_operand (char const *file, struct stat *st, bool *new_dst) if (err) { if (err != ENOENT) - error (EXIT_FAILURE, err, _("failed to access %s"), quote (file)); + error (EXIT_FAILURE, err, _("failed to access %s"), quoteaf (file)); *new_dst = true; } return is_a_dir; @@ -597,7 +597,7 @@ do_copy (int n_files, char **file, const char *target_directory, error (0, 0, _("missing file operand")); else error (0, 0, _("missing destination file operand after %s"), - quote (file[0])); + quoteaf (file[0])); usage (EXIT_FAILURE); } @@ -609,7 +609,7 @@ do_copy (int n_files, char **file, const char *target_directory, "and --no-target-directory (-T)")); if (2 < n_files) { - error (0, 0, _("extra operand %s"), quote (file[2])); + error (0, 0, _("extra operand %s"), quoteaf (file[2])); usage (EXIT_FAILURE); } /* Update NEW_DST and SB, which may be checked below. */ @@ -622,7 +622,7 @@ do_copy (int n_files, char **file, const char *target_directory, target_directory = file[--n_files]; else if (2 < n_files) error (EXIT_FAILURE, 0, _("target %s is not a directory"), - quote (file[n_files - 1])); + quoteaf (file[n_files - 1])); } if (target_directory) @@ -1077,10 +1077,10 @@ main (int argc, char **argv) struct stat st; if (stat (optarg, &st) != 0) error (EXIT_FAILURE, errno, _("failed to access %s"), - quote (optarg)); + quoteaf (optarg)); if (! S_ISDIR (st.st_mode)) error (EXIT_FAILURE, 0, _("target %s is not a directory"), - quote (optarg)); + quoteaf (optarg)); } target_directory = optarg; break; diff --git a/src/csplit.c b/src/csplit.c index 6507c1177..c97acb862 100644 --- a/src/csplit.c +++ b/src/csplit.c @@ -651,7 +651,8 @@ static void set_input_file (const char *name) { if (! STREQ (name, "-") && fd_reopen (STDIN_FILENO, name, O_RDONLY, 0) < 0) - error (EXIT_FAILURE, errno, _("cannot open %s for reading"), quote (name)); + error (EXIT_FAILURE, errno, _("cannot open %s for reading"), + quoteaf (name)); } /* Write all lines from the beginning of the buffer up to, but @@ -969,7 +970,7 @@ create_output_file (void) if (! fopen_ok) { - error (0, fopen_errno, "%s", quote (output_filename)); + error (0, fopen_errno, "%s", quotef (output_filename)); cleanup_fatal (); } bytes_written = 0; @@ -990,7 +991,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", quote (name)); + error (0, errno, "%s", quotef (name)); } files_created = 0; @@ -1006,13 +1007,13 @@ close_output_file (void) { if (ferror (output_stream)) { - error (0, 0, _("write error for %s"), quote (output_filename)); + error (0, 0, _("write error for %s"), quoteaf (output_filename)); output_stream = NULL; cleanup_fatal (); } if (fclose (output_stream) != 0) { - error (0, errno, "%s", quote (output_filename)); + error (0, errno, "%s", quotef (output_filename)); output_stream = NULL; cleanup_fatal (); } @@ -1030,7 +1031,7 @@ close_output_file (void) sigprocmask (SIG_SETMASK, &oldset, NULL); if (! unlink_ok) - error (0, unlink_errno, "%s", quote (output_filename)); + error (0, unlink_errno, "%s", quotef (output_filename)); } else { @@ -34,7 +34,6 @@ #include "fadvise.h" #include "getndelim2.h" #include "hash.h" -#include "quote.h" #include "xstrndup.h" #include "set-fields.h" @@ -445,7 +444,7 @@ cut_file (char const *file) stream = fopen (file, "r"); if (stream == NULL) { - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); return false; } } @@ -456,14 +455,14 @@ cut_file (char const *file) if (ferror (stream)) { - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); return false; } if (STREQ (file, "-")) clearerr (stream); /* Also clear EOF. */ else if (fclose (stream) == EOF) { - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); return false; } return true; diff --git a/src/date.c b/src/date.c index 50e71d74a..5c3e5da7d 100644 --- a/src/date.c +++ b/src/date.c @@ -290,7 +290,7 @@ batch_convert (const char *input_filename, const char *format, timezone_t tz) in_stream = fopen (input_filename, "r"); if (in_stream == NULL) { - error (EXIT_FAILURE, errno, "%s", quote (input_filename)); + error (EXIT_FAILURE, errno, "%s", quotef (input_filename)); } } @@ -320,7 +320,7 @@ batch_convert (const char *input_filename, const char *format, timezone_t tz) } if (fclose (in_stream) == EOF) - error (EXIT_FAILURE, errno, "%s", quote (input_filename)); + error (EXIT_FAILURE, errno, "%s", quotef (input_filename)); free (line); @@ -520,7 +520,7 @@ main (int argc, char **argv) if (reference != NULL) { if (stat (reference, &refstats) != 0) - error (EXIT_FAILURE, errno, "%s", quote (reference)); + error (EXIT_FAILURE, errno, "%s", quotef (reference)); when = get_stat_mtime (&refstats); } else @@ -32,7 +32,6 @@ #include "human.h" #include "long-options.h" #include "quote.h" -#include "quotearg.h" #include "verror.h" #include "xstrtol.h" #include "xtime.h" @@ -911,14 +910,14 @@ cleanup (void) { if (close (STDIN_FILENO) < 0) error (EXIT_FAILURE, errno, - _("closing input file %s"), quote (input_file)); + _("closing input file %s"), quoteaf (input_file)); /* Don't remove this call to close, even though close_stdout closes standard output. This close is necessary when cleanup is called as part of a signal handler. */ if (close (STDOUT_FILENO) < 0) error (EXIT_FAILURE, errno, - _("closing output file %s"), quote (output_file)); + _("closing output file %s"), quoteaf (output_file)); } /* Process any pending signals. If signals are caught, this function @@ -1134,7 +1133,7 @@ iwrite (int fd, char const *buf, size_t size) if (fcntl (STDOUT_FILENO, F_SETFL, old_flags & ~O_DIRECT) != 0 && status_level != STATUS_NONE) error (0, errno, _("failed to turn off O_DIRECT: %s"), - quote (output_file)); + quotef (output_file)); /* Since we have just turned off O_DIRECT for the final write, here we try to preserve some of its semantics. First, use @@ -1204,7 +1203,7 @@ write_output (void) w_bytes += nwritten; if (nwritten != output_blocksize) { - error (0, errno, _("writing to %s"), quote (output_file)); + error (0, errno, _("writing to %s"), quoteaf (output_file)); if (nwritten != 0) w_partial++; quit (EXIT_FAILURE); @@ -1356,7 +1355,8 @@ scanargs (int argc, char *const *argv) if (val == NULL) { - error (0, 0, _("unrecognized operand %s"), quote (name)); + error (0, 0, _("unrecognized operand %s"), + quote (name)); usage (EXIT_FAILURE); } val++; @@ -1416,7 +1416,8 @@ scanargs (int argc, char *const *argv) count = n; else { - error (0, 0, _("unrecognized operand %s"), quote (name)); + error (0, 0, _("unrecognized operand %s"), + quote (name)); usage (EXIT_FAILURE); } @@ -1718,7 +1719,7 @@ skip (int fdesc, char const *file, uintmax_t records, size_t blocksize, { struct stat st; if (fstat (STDIN_FILENO, &st) != 0) - error (EXIT_FAILURE, errno, _("cannot fstat %s"), quote (file)); + error (EXIT_FAILURE, errno, _("cannot fstat %s"), quoteaf (file)); if (usable_st_size (&st) && st.st_size < input_offset + offset) { /* When skipping past EOF, return the number of _full_ blocks @@ -1765,9 +1766,9 @@ skip (int fdesc, char const *file, uintmax_t records, size_t blocksize, } if (fdesc == STDIN_FILENO) - error (0, lseek_errno, _("%s: cannot skip"), quote (file)); + error (0, lseek_errno, _("%s: cannot skip"), quotef (file)); else - error (0, lseek_errno, _("%s: cannot seek"), quote (file)); + error (0, lseek_errno, _("%s: cannot seek"), quotef (file)); /* If the file has a specific size and we've asked to skip/seek beyond the max allowable, then quit. */ quit (EXIT_FAILURE); @@ -1793,12 +1794,12 @@ skip (int fdesc, char const *file, uintmax_t records, size_t blocksize, { if (fdesc == STDIN_FILENO) { - error (0, errno, _("error reading %s"), quote (file)); + error (0, errno, _("error reading %s"), quoteaf (file)); if (conversions_mask & C_NOERROR) print_stats (); } else - error (0, lseek_errno, _("%s: cannot seek"), quote (file)); + error (0, lseek_errno, _("%s: cannot seek"), quotef (file)); quit (EXIT_FAILURE); } else if (nread == 0) @@ -1840,7 +1841,7 @@ advance_input_after_read_error (size_t nbytes) if (input_offset_overflow) { error (0, 0, _("offset overflow while reading file %s"), - quote (input_file)); + quoteaf (input_file)); return false; } offset = lseek (STDIN_FILENO, 0, SEEK_CUR); @@ -1859,7 +1860,7 @@ advance_input_after_read_error (size_t nbytes) } } - error (0, errno, _("%s: cannot seek"), quote (input_file)); + error (0, errno, _("%s: cannot seek"), quotef (input_file)); return false; } @@ -1998,7 +1999,7 @@ set_fd_flags (int fd, int add_flags, char const *name) } if (!ok) - error (EXIT_FAILURE, errno, _("setting flags for %s"), quote (name)); + error (EXIT_FAILURE, errno, _("setting flags for %s"), quoteaf (name)); } } @@ -2052,7 +2053,7 @@ dd_copy (void) && status_level != STATUS_NONE) { error (0, 0, - _("%s: cannot skip to specified offset"), quote (input_file)); + _("%s: cannot skip to specified offset"), quotef (input_file)); } } @@ -2071,7 +2072,7 @@ dd_copy (void) size_t size = write_records ? output_blocksize : bytes; if (iwrite (STDOUT_FILENO, obuf, size) != size) { - error (0, errno, _("writing to %s"), quote (output_file)); + error (0, errno, _("writing to %s"), quoteaf (output_file)); quit (EXIT_FAILURE); } @@ -2130,7 +2131,7 @@ dd_copy (void) if (nread < 0) { if (!(conversions_mask & C_NOERROR) || status_level != STATUS_NONE) - error (0, errno, _("error reading %s"), quote (input_file)); + error (0, errno, _("error reading %s"), quoteaf (input_file)); if (conversions_mask & C_NOERROR) { @@ -2194,7 +2195,7 @@ dd_copy (void) w_bytes += nwritten; if (nwritten != n_bytes_read) { - error (0, errno, _("error writing %s"), quote (output_file)); + error (0, errno, _("error writing %s"), quoteaf (output_file)); return EXIT_FAILURE; } else if (n_bytes_read == input_blocksize) @@ -2257,7 +2258,7 @@ dd_copy (void) w_partial++; if (nwritten != oc) { - error (0, errno, _("error writing %s"), quote (output_file)); + error (0, errno, _("error writing %s"), quoteaf (output_file)); return EXIT_FAILURE; } } @@ -2269,7 +2270,7 @@ dd_copy (void) struct stat stdout_stat; if (fstat (STDOUT_FILENO, &stdout_stat) != 0) { - error (0, errno, _("cannot fstat %s"), quote (output_file)); + error (0, errno, _("cannot fstat %s"), quoteaf (output_file)); return EXIT_FAILURE; } if (S_ISREG (stdout_stat.st_mode) || S_TYPEISSHM (&stdout_stat)) @@ -2282,7 +2283,7 @@ dd_copy (void) error (0, errno, _("failed to truncate to %" PRIdMAX " bytes" " in output file %s"), - (intmax_t) output_offset, quote (output_file)); + (intmax_t) output_offset, quoteaf (output_file)); return EXIT_FAILURE; } } @@ -2293,7 +2294,7 @@ dd_copy (void) { if (errno != ENOSYS && errno != EINVAL) { - error (0, errno, _("fdatasync failed for %s"), quote (output_file)); + error (0, errno, _("fdatasync failed for %s"), quoteaf (output_file)); exit_status = EXIT_FAILURE; } conversions_mask |= C_FSYNC; @@ -2303,7 +2304,7 @@ dd_copy (void) while (fsync (STDOUT_FILENO) != 0) if (errno != EINTR) { - error (0, errno, _("fsync failed for %s"), quote (output_file)); + error (0, errno, _("fsync failed for %s"), quoteaf (output_file)); return EXIT_FAILURE; } @@ -2354,7 +2355,8 @@ main (int argc, char **argv) else { if (ifd_reopen (STDIN_FILENO, input_file, O_RDONLY | input_flags, 0) < 0) - error (EXIT_FAILURE, errno, _("failed to open %s"), quote (input_file)); + error (EXIT_FAILURE, errno, _("failed to open %s"), + quoteaf (input_file)); } offset = lseek (STDIN_FILENO, 0, SEEK_CUR); @@ -2384,7 +2386,7 @@ main (int argc, char **argv) && (ifd_reopen (STDOUT_FILENO, output_file, O_WRONLY | opts, perms) < 0)) error (EXIT_FAILURE, errno, _("failed to open %s"), - quote (output_file)); + quoteaf (output_file)); if (seek_records != 0 && !(conversions_mask & C_NOTRUNC)) { @@ -2409,14 +2411,14 @@ main (int argc, char **argv) struct stat stdout_stat; if (fstat (STDOUT_FILENO, &stdout_stat) != 0) error (EXIT_FAILURE, errno, _("cannot fstat %s"), - quote (output_file)); + quoteaf (output_file)); if (S_ISREG (stdout_stat.st_mode) || S_ISDIR (stdout_stat.st_mode) || S_TYPEISSHM (&stdout_stat)) error (EXIT_FAILURE, ftruncate_errno, _("failed to truncate to %"PRIuMAX" bytes" " in output file %s"), - size, quote (output_file)); + size, quoteaf (output_file)); } } } @@ -2431,13 +2433,13 @@ main (int argc, char **argv) if (i_nocache && !invalidate_cache (STDIN_FILENO, 0)) { error (0, errno, _("failed to discard cache for: %s"), - quote (input_file)); + quotef (input_file)); exit_status = EXIT_FAILURE; } if (o_nocache && !invalidate_cache (STDOUT_FILENO, 0)) { error (0, errno, _("failed to discard cache for: %s"), - quote (output_file)); + quotef (output_file)); exit_status = EXIT_FAILURE; } } @@ -938,7 +938,7 @@ get_dev (char const *disk, char const *mount_point, char const* file, } else { - error (0, errno, "%s", quote (stat_file)); + error (0, errno, "%s", quotef (stat_file)); exit_status = EXIT_FAILURE; return; } @@ -1240,7 +1240,7 @@ get_disk (char const *disk) else if (eclipsed_device) { error (0, 0, _("cannot access %s: over-mounted by another device"), - quote (file)); + quoteaf (file)); exit_status = EXIT_FAILURE; return true; } @@ -1304,7 +1304,7 @@ get_point (const char *point, const struct stat *statp) can't possibly be on this file system. */ if (errno == EIO) { - error (0, errno, "%s", quote (me->me_mountdir)); + error (0, errno, "%s", quotef (me->me_mountdir)); exit_status = EXIT_FAILURE; } @@ -1668,7 +1668,7 @@ main (int argc, char **argv) if ((fd < 0 || fstat (fd, &stats[i - optind])) && stat (argv[i], &stats[i - optind])) { - error (0, errno, "%s", quote (argv[i])); + error (0, errno, "%s", quotef (argv[i])); exit_status = EXIT_FAILURE; argv[i] = NULL; } diff --git a/src/dircolors.c b/src/dircolors.c index f93b997a6..908835eb3 100644 --- a/src/dircolors.c +++ b/src/dircolors.c @@ -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"), - quote (filename), (unsigned long int) line_number); + quotef (filename), (unsigned long int) line_number); ok = false; free (keywd); continue; @@ -357,7 +357,7 @@ dc_parse_stream (FILE *fp, const char *filename) if (unrecognized && (state == ST_TERMSURE || state == ST_TERMYES)) { error (0, 0, _("%s:%lu: unrecognized keyword %s"), - (filename ? quote (filename) : _("<internal>")), + (filename ? quotef (filename) : _("<internal>")), (unsigned long int) line_number, keywd); ok = false; } @@ -376,7 +376,7 @@ dc_parse_file (const char *filename) if (! STREQ (filename, "-") && freopen (filename, "r", stdin) == NULL) { - error (0, errno, "%s", quote (filename)); + error (0, errno, "%s", quotef (filename)); return false; } @@ -384,7 +384,7 @@ dc_parse_file (const char *filename) if (fclose (stdin) != 0) { - error (0, errno, "%s", quote (filename)); + error (0, errno, "%s", quotef (filename)); return false; } @@ -506,7 +506,7 @@ process_file (FTS *fts, FTSENT *ent) if (info == FTS_DNR) { /* An error occurred, but the size is known, so count it. */ - error (0, ent->fts_errno, _("cannot read directory %s"), quote (file)); + error (0, ent->fts_errno, _("cannot read directory %s"), quoteaf (file)); ok = false; } else if (info != FTS_DP) @@ -526,7 +526,7 @@ process_file (FTS *fts, FTSENT *ent) if (info == FTS_NS || info == FTS_SLNONE) { - error (0, ent->fts_errno, _("cannot access %s"), quote (file)); + error (0, ent->fts_errno, _("cannot access %s"), quoteaf (file)); return false; } @@ -566,7 +566,7 @@ process_file (FTS *fts, FTSENT *ent) case FTS_ERR: /* An error occurred, but the size is known, so count it. */ - error (0, ent->fts_errno, "%s", quote (file)); + error (0, ent->fts_errno, "%s", quotef (file)); ok = false; break; @@ -691,7 +691,7 @@ du_files (char **files, int bit_flags) if (errno != 0) { error (0, errno, _("fts_read failed: %s"), - quote (fts->fts_path)); + quotef (fts->fts_path)); ok = false; } @@ -882,7 +882,7 @@ main (int argc, char **argv) if (add_exclude_file (add_exclude, exclude, optarg, EXCLUDE_WILDCARDS, '\n')) { - error (0, errno, "%s", quote (optarg)); + error (0, errno, "%s", quotef (optarg)); ok = false; } break; @@ -1020,7 +1020,7 @@ main (int argc, char **argv) if (! (STREQ (files_from, "-") || freopen (files_from, "r", stdin))) error (EXIT_FAILURE, errno, _("cannot open %s for reading"), - quote (files_from)); + quoteaf (files_from)); ai = argv_iter_init_stream (stdin); @@ -1068,7 +1068,7 @@ main (int argc, char **argv) goto argv_iter_done; case AI_ERR_READ: error (0, errno, _("%s: read error"), - quote (files_from)); + quotef (files_from)); ok = false; goto argv_iter_done; case AI_ERR_MEM: @@ -1083,7 +1083,7 @@ main (int argc, char **argv) printf - | du --files0-from=- */ error (0, 0, _("when reading file names from stdin, " "no file name of %s allowed"), - quote (file_name)); + quoteaf (file_name)); skip_file = true; } @@ -1105,7 +1105,7 @@ main (int argc, char **argv) not totally appropriate, since NUL is the separator, not NL, but it might be better than nothing. */ unsigned long int file_number = argv_iter_n_args (ai); - error (0, 0, "%s:%lu: %s", quote (files_from), + error (0, 0, "%s:%lu: %s", quotef (files_from), file_number, _("invalid zero-length file name")); } skip_file = true; @@ -1127,7 +1127,7 @@ main (int argc, char **argv) di_set_free (di_mnt); if (files_from && (ferror (stdin) || fclose (stdin) != 0) && ok) - error (EXIT_FAILURE, 0, _("error reading %s"), quote (files_from)); + error (EXIT_FAILURE, 0, _("error reading %s"), quoteaf (files_from)); if (print_grand_total) print_size (&tot_dui, _("total")); diff --git a/src/expand.c b/src/expand.c index 843bb87be..563a9e956 100644 --- a/src/expand.c +++ b/src/expand.c @@ -224,14 +224,14 @@ next_file (FILE *fp) { if (ferror (fp)) { - error (0, errno, "%s", quote (prev_file)); + error (0, errno, "%s", quotef (prev_file)); exit_status = EXIT_FAILURE; } if (STREQ (prev_file, "-")) clearerr (fp); /* Also clear EOF. */ else if (fclose (fp) != 0) { - error (0, errno, "%s", quote (prev_file)); + error (0, errno, "%s", quotef (prev_file)); exit_status = EXIT_FAILURE; } } @@ -251,7 +251,7 @@ next_file (FILE *fp) fadvise (fp, FADVISE_SEQUENTIAL); return fp; } - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); exit_status = EXIT_FAILURE; } return NULL; diff --git a/src/expr.c b/src/expr.c index 536e68131..59332b184 100644 --- a/src/expr.c +++ b/src/expr.c @@ -36,7 +36,6 @@ #include <regex.h> #include "error.h" #include "long-options.h" -#include "quotearg.h" #include "strnumcmp.h" #include "xstrtol.h" diff --git a/src/find-mount-point.c b/src/find-mount-point.c index 59a60e271..586bd2f33 100644 --- a/src/find-mount-point.c +++ b/src/find-mount-point.c @@ -19,7 +19,6 @@ #include "system.h" #include "error.h" -#include "quote.h" #include "save-cwd.h" #include "xgetcwd.h" #include "find-mount-point.h" @@ -47,7 +46,7 @@ find_mount_point (char const *file, struct stat const *file_stat) last_stat = *file_stat; if (chdir (file) < 0) { - error (0, errno, _("cannot change to directory %s"), quote (file)); + error (0, errno, _("cannot change to directory %s"), quoteaf (file)); return NULL; } } @@ -61,14 +60,14 @@ find_mount_point (char const *file, struct stat const *file_stat) if (chdir (dir) < 0) { - error (0, errno, _("cannot change to directory %s"), quote (dir)); + error (0, errno, _("cannot change to directory %s"), quoteaf (dir)); return NULL; } if (stat (".", &last_stat) < 0) { error (0, errno, _("cannot stat current directory (now %s)"), - quote (dir)); + quoteaf (dir)); goto done; } } @@ -81,7 +80,7 @@ find_mount_point (char const *file, struct stat const *file_stat) struct stat st; if (stat ("..", &st) < 0) { - error (0, errno, _("cannot stat %s"), quote ("..")); + error (0, errno, _("cannot stat %s"), quoteaf ("..")); goto done; } if (st.st_dev != last_stat.st_dev || st.st_ino == last_stat.st_ino) @@ -89,7 +88,7 @@ find_mount_point (char const *file, struct stat const *file_stat) break; if (chdir ("..") < 0) { - error (0, errno, _("cannot change to directory %s"), quote ("..")); + error (0, errno, _("cannot change to directory %s"), quoteaf ("..")); goto done; } last_stat = st; @@ -29,7 +29,6 @@ #include "system.h" #include "error.h" #include "fadvise.h" -#include "quote.h" #include "xdectoint.h" /* The official name of this program (e.g., no 'g' prefix). */ @@ -431,14 +430,14 @@ main (int argc, char **argv) fmt (in_stream); if (fclose (in_stream) == EOF) { - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); ok = false; } } else { error (0, errno, _("cannot open %s for reading"), - quote (file)); + quoteaf (file)); ok = false; } } diff --git a/src/fold.c b/src/fold.c index 2f917f400..4a445d50b 100644 --- a/src/fold.c +++ b/src/fold.c @@ -25,7 +25,6 @@ #include "system.h" #include "error.h" #include "fadvise.h" -#include "quote.h" #include "xdectoint.h" #define TAB_WIDTH 8 @@ -137,7 +136,7 @@ fold_file (char const *filename, size_t width) if (istream == NULL) { - error (0, errno, "%s", quote (filename)); + error (0, errno, "%s", quotef (filename)); return false; } @@ -222,14 +221,14 @@ fold_file (char const *filename, size_t width) if (ferror (istream)) { - error (0, saved_errno, "%s", quote (filename)); + error (0, saved_errno, "%s", quotef (filename)); if (!STREQ (filename, "-")) fclose (istream); return false; } if (!STREQ (filename, "-") && fclose (istream) == EOF) { - error (0, errno, "%s", quote (filename)); + error (0, errno, "%s", quotef (filename)); return false; } diff --git a/src/head.c b/src/head.c index a77376d10..e05c21935 100644 --- a/src/head.c +++ b/src/head.c @@ -145,10 +145,10 @@ diagnose_copy_fd_failure (enum Copy_fd_status err, char const *filename) switch (err) { case COPY_FD_READ_ERROR: - error (0, errno, _("error reading %s"), quote (filename)); + error (0, errno, _("error reading %s"), quoteaf (filename)); break; case COPY_FD_UNEXPECTED_EOF: - error (0, errno, _("%s: file has shrunk too much"), quote (filename)); + error (0, errno, _("%s: file has shrunk too much"), quotef (filename)); break; default: abort (); @@ -174,7 +174,7 @@ xwrite_stdout (char const *buffer, size_t n_bytes) { clearerr (stdout); /* To avoid redundant close_stdout diagnostic. */ error (EXIT_FAILURE, errno, _("error writing %s"), - quote ("standard output")); + quoteaf ("standard output")); } } @@ -222,7 +222,7 @@ elseek (int fd, off_t offset, int whence, char const *filename) _(whence == SEEK_SET ? N_("%s: cannot seek to offset %s") : N_("%s: cannot seek to relative offset %s")), - quote (filename), + quotef (filename), offtostr (offset, buf)); return new_offset; @@ -296,7 +296,7 @@ elide_tail_bytes_pipe (const char *filename, int fd, uintmax_t n_elide_0, { if (errno != 0) { - error (0, errno, _("error reading %s"), quote (filename)); + error (0, errno, _("error reading %s"), quoteaf (filename)); ok = false; break; } @@ -378,7 +378,7 @@ elide_tail_bytes_pipe (const char *filename, int fd, uintmax_t n_elide_0, { if (errno != 0) { - error (0, errno, _("error reading %s"), quote (filename)); + error (0, errno, _("error reading %s"), quoteaf (filename)); ok = false; goto free_mem; } @@ -574,7 +574,7 @@ elide_tail_lines_pipe (const char *filename, int fd, uintmax_t n_elide, if (n_read == SAFE_READ_ERROR) { - error (0, errno, _("error reading %s"), quote (filename)); + error (0, errno, _("error reading %s"), quoteaf (filename)); ok = false; goto free_lbuffers; } @@ -656,7 +656,7 @@ elide_tail_lines_seekable (const char *pretty_filename, int fd, bytes_read = safe_read (fd, buffer, bytes_read); if (bytes_read == SAFE_READ_ERROR) { - error (0, errno, _("error reading %s"), quote (pretty_filename)); + error (0, errno, _("error reading %s"), quoteaf (pretty_filename)); return false; } @@ -725,7 +725,7 @@ elide_tail_lines_seekable (const char *pretty_filename, int fd, bytes_read = safe_read (fd, buffer, BUFSIZ); if (bytes_read == SAFE_READ_ERROR) { - error (0, errno, _("error reading %s"), quote (pretty_filename)); + error (0, errno, _("error reading %s"), quoteaf (pretty_filename)); return false; } @@ -775,7 +775,7 @@ head_bytes (const char *filename, int fd, uintmax_t bytes_to_write) bytes_read = safe_read (fd, buffer, bytes_to_read); if (bytes_read == SAFE_READ_ERROR) { - error (0, errno, _("error reading %s"), quote (filename)); + error (0, errno, _("error reading %s"), quoteaf (filename)); return false; } if (bytes_read == 0) @@ -798,7 +798,7 @@ head_lines (const char *filename, int fd, uintmax_t lines_to_write) if (bytes_read == SAFE_READ_ERROR) { - error (0, errno, _("error reading %s"), quote (filename)); + error (0, errno, _("error reading %s"), quoteaf (filename)); return false; } if (bytes_read == 0) @@ -837,7 +837,7 @@ head (const char *filename, int fd, uintmax_t n_units, bool count_lines, if (fstat (fd, &st) != 0) { error (0, errno, _("cannot fstat %s"), - quote (filename)); + quoteaf (filename)); return false; } if (! presume_input_pipe && usable_st_size (&st)) @@ -878,7 +878,7 @@ head_file (const char *filename, uintmax_t n_units, bool count_lines, fd = open (filename, O_RDONLY | O_BINARY); if (fd < 0) { - error (0, errno, _("cannot open %s for reading"), quote (filename)); + error (0, errno, _("cannot open %s for reading"), quoteaf (filename)); return false; } } @@ -886,7 +886,7 @@ head_file (const char *filename, uintmax_t n_units, bool count_lines, ok = head (filename, fd, n_units, count_lines, elide_from_end); if (!is_stdin && close (fd) != 0) { - error (0, errno, _("failed to close %s"), quote (filename)); + error (0, errno, _("failed to close %s"), quoteaf (filename)); return false; } return ok; diff --git a/src/hostname.c b/src/hostname.c index 371a2e1d9..bc421d144 100644 --- a/src/hostname.c +++ b/src/hostname.c @@ -91,7 +91,8 @@ main (int argc, char **argv) /* Set hostname to operand. */ char const *name = argv[optind]; if (sethostname (name, strlen (name)) != 0) - error (EXIT_FAILURE, errno, _("cannot set name to %s"), quote (name)); + error (EXIT_FAILURE, errno, _("cannot set name to %s"), + quote (name)); #else error (EXIT_FAILURE, 0, _("cannot set hostname; this system lacks the functionality")); diff --git a/src/install.c b/src/install.c index d338cbb29..66e2ea53d 100644 --- a/src/install.c +++ b/src/install.c @@ -373,7 +373,7 @@ setdefaultfilecon (char const *file) if (lsetfilecon (file, scontext) < 0 && errno != ENOTSUP) error (0, errno, _("warning: %s: failed to change context to %s"), - quote_n (0, file), quote_n (1, scontext)); + quotef_n (0, file), quote_n (1, scontext)); freecon (scontext); return; @@ -401,9 +401,10 @@ target_directory_operand (char const *file) int err = (stat (file, &st) == 0 ? 0 : errno); bool is_a_dir = !err && S_ISDIR (st.st_mode); if (err && err != ENOENT) - error (EXIT_FAILURE, err, _("failed to access %s"), quote (file)); + error (EXIT_FAILURE, err, _("failed to access %s"), quoteaf (file)); if (is_a_dir < looks_like_a_dir) - error (EXIT_FAILURE, err, _("target %s is not a directory"), quote (file)); + error (EXIT_FAILURE, err, _("target %s is not a directory"), + quoteaf (file)); return is_a_dir; } @@ -413,7 +414,7 @@ announce_mkdir (char const *dir, void *options) { struct cp_options const *x = options; if (x->verbose) - prog_fprintf (stdout, _("creating directory %s"), quote (dir)); + prog_fprintf (stdout, _("creating directory %s"), quoteaf (dir)); } /* Make ancestor directory DIR, whose last file name component is @@ -481,9 +482,9 @@ change_attributes (char const *name) if (! (owner_id == (uid_t) -1 && group_id == (gid_t) -1) && lchown (name, owner_id, group_id) != 0) - error (0, errno, _("cannot change ownership of %s"), quote (name)); + error (0, errno, _("cannot change ownership of %s"), quoteaf (name)); else if (chmod (name, mode) != 0) - error (0, errno, _("cannot change permissions of %s"), quote (name)); + error (0, errno, _("cannot change permissions of %s"), quoteaf (name)); else ok = true; @@ -505,7 +506,7 @@ change_timestamps (struct stat const *src_sb, char const *dest) if (utimens (dest, timespec)) { - error (0, errno, _("cannot set time stamps for %s"), quote (dest)); + error (0, errno, _("cannot set time stamps for %s"), quoteaf (dest)); return false; } return true; @@ -531,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"), quote (strip_program)); + error (EXIT_FAILURE, errno, _("cannot run %s"), quoteaf (strip_program)); break; default: /* Parent. */ if (waitpid (pid, &status, 0) < 0) @@ -561,7 +562,8 @@ get_ids (void) unsigned long int tmp; if (xstrtoul (owner_name, NULL, 0, &tmp, NULL) != LONGINT_OK || UID_T_MAX < tmp) - error (EXIT_FAILURE, 0, _("invalid user %s"), quote (owner_name)); + error (EXIT_FAILURE, 0, _("invalid user %s"), + quote (owner_name)); owner_id = tmp; } else @@ -579,7 +581,8 @@ get_ids (void) unsigned long int tmp; if (xstrtoul (group_name, NULL, 0, &tmp, NULL) != LONGINT_OK || GID_T_MAX < tmp) - error (EXIT_FAILURE, 0, _("invalid group %s"), quote (group_name)); + error (EXIT_FAILURE, 0, _("invalid group %s"), + quote (group_name)); group_id = tmp; } else @@ -683,7 +686,7 @@ install_file_in_file (const char *from, const char *to, struct stat from_sb; if (x->preserve_timestamps && stat (from, &from_sb) != 0) { - error (0, errno, _("cannot stat %s"), quote (from)); + error (0, errno, _("cannot stat %s"), quoteaf (from)); return false; } if (! copy_file (from, to, x)) @@ -692,7 +695,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"), quote (to)); + error (EXIT_FAILURE, errno, _("cannot unlink %s"), quoteaf (to)); return false; } if (x->preserve_timestamps && (strip_files || ! S_ISREG (from_sb.st_mode)) @@ -718,7 +721,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"), quote (to)); + error (0, errno, _("cannot create directory %s"), quoteaf (to)); status = EXIT_FAILURE; } @@ -731,7 +734,8 @@ 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"), quote (to)); + error (0, restore_errno, _("cannot create directory %s"), + quoteaf (to)); return false; } } @@ -924,10 +928,10 @@ main (int argc, char **argv) bool stat_success = stat (target_directory, &st) == 0 ? true : false; if (! mkdir_and_install && ! stat_success) error (EXIT_FAILURE, errno, _("failed to access %s"), - quote (target_directory)); + quoteaf (target_directory)); if (stat_success && ! S_ISDIR (st.st_mode)) error (EXIT_FAILURE, 0, _("target %s is not a directory"), - quote (target_directory)); + quoteaf (target_directory)); } if (backup_suffix_string) @@ -956,7 +960,7 @@ main (int argc, char **argv) error (0, 0, _("missing file operand")); else error (0, 0, _("missing destination file operand after %s"), - quote (file[0])); + quoteaf (file[0])); usage (EXIT_FAILURE); } @@ -968,7 +972,7 @@ main (int argc, char **argv) "and --no-target-directory (-T)")); if (2 < n_files) { - error (0, 0, _("extra operand %s"), quote (file[2])); + error (0, 0, _("extra operand %s"), quoteaf (file[2])); usage (EXIT_FAILURE); } } @@ -978,7 +982,7 @@ main (int argc, char **argv) target_directory = file[--n_files]; else if (2 < n_files) error (EXIT_FAILURE, 0, _("target %s is not a directory"), - quote (file[n_files - 1])); + quoteaf (file[n_files - 1])); } if (specified_mode) diff --git a/src/join.c b/src/join.c index ffef70f77..08af0156a 100644 --- a/src/join.c +++ b/src/join.c @@ -971,7 +971,7 @@ add_file_name (char *name, char *names[2], switch (operand_status[op0]) { case MUST_BE_OPERAND: - error (0, 0, _("extra operand %s"), quote (name)); + error (0, 0, _("extra operand %s"), quoteaf (name)); usage (EXIT_FAILURE); case MIGHT_BE_J1_ARG: @@ -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", quote (g_names[0])); + error (EXIT_FAILURE, errno, "%s", quotef (g_names[0])); fp2 = STREQ (g_names[1], "-") ? stdin : fopen (g_names[1], "r"); if (!fp2) - error (EXIT_FAILURE, errno, "%s", quote (g_names[1])); + error (EXIT_FAILURE, errno, "%s", quotef (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", quote (g_names[0])); + error (EXIT_FAILURE, errno, "%s", quotef (g_names[0])); if (fclose (fp2) != 0) - error (EXIT_FAILURE, errno, "%s", quote (g_names[1])); + error (EXIT_FAILURE, errno, "%s", quotef (g_names[1])); if (issued_disorder_warning[0] || issued_disorder_warning[1]) return EXIT_FAILURE; diff --git a/src/link.c b/src/link.c index bbd182920..bee03feb5 100644 --- a/src/link.c +++ b/src/link.c @@ -88,7 +88,7 @@ main (int argc, char **argv) if (link (argv[optind], argv[optind + 1]) != 0) error (EXIT_FAILURE, errno, _("cannot create link %s to %s"), - quote_n (0, argv[optind + 1]), quote_n (1, argv[optind])); + quoteaf_n (0, argv[optind + 1]), quoteaf_n (1, argv[optind])); return EXIT_SUCCESS; } @@ -28,7 +28,6 @@ #include "file-set.h" #include "hash.h" #include "hash-triple.h" -#include "quote.h" #include "relpath.h" #include "same.h" #include "yesno.h" @@ -130,9 +129,10 @@ target_directory_operand (char const *file) int err = (stat_result == 0 ? 0 : errno); bool is_a_dir = !err && S_ISDIR (st.st_mode); if (err && ! errno_nonexisting (errno)) - error (EXIT_FAILURE, err, _("failed to access %s"), quote (file)); + error (EXIT_FAILURE, err, _("failed to access %s"), quoteaf (file)); if (is_a_dir < looks_like_a_dir) - error (EXIT_FAILURE, err, _("target %s is not a directory"), quote (file)); + error (EXIT_FAILURE, err, _("target %s is not a directory"), + quoteaf (file)); return is_a_dir; } @@ -194,7 +194,7 @@ do_link (const char *source, const char *dest) : lstat (source, &source_stats)) != 0) { - error (0, errno, _("failed to access %s"), quote (source)); + error (0, errno, _("failed to access %s"), quoteaf (source)); return false; } @@ -204,7 +204,7 @@ do_link (const char *source, const char *dest) if (! hard_dir_link) { error (0, 0, _("%s: hard link not allowed for directory"), - quote (source)); + quotef (source)); return false; } } @@ -215,7 +215,7 @@ do_link (const char *source, const char *dest) dest_lstat_ok = (lstat (dest, &dest_stats) == 0); if (!dest_lstat_ok && errno != ENOENT) { - error (0, errno, _("failed to access %s"), quote (dest)); + error (0, errno, _("failed to access %s"), quoteaf (dest)); return false; } } @@ -228,7 +228,7 @@ do_link (const char *source, const char *dest) { error (0, 0, _("will not overwrite just-created %s with %s"), - quote_n (0, dest), quote_n (1, source)); + quoteaf_n (0, dest), quoteaf_n (1, source)); return false; } @@ -260,7 +260,7 @@ do_link (const char *source, const char *dest) && (source_stats.st_nlink == 1 || same_name (source, dest))) { error (0, 0, _("%s and %s are the same file"), - quote_n (0, source), quote_n (1, dest)); + quoteaf_n (0, source), quoteaf_n (1, dest)); return false; } @@ -268,12 +268,12 @@ do_link (const char *source, const char *dest) { if (S_ISDIR (dest_stats.st_mode)) { - error (0, 0, _("%s: cannot overwrite directory"), quote (dest)); + error (0, 0, _("%s: cannot overwrite directory"), quotef (dest)); return false; } if (interactive) { - fprintf (stderr, _("%s: replace %s? "), program_name, quote (dest)); + fprintf (stderr, _("%s: replace %s? "), program_name, quoteaf (dest)); if (!yesno ()) return true; remove_existing_files = true; @@ -289,7 +289,8 @@ do_link (const char *source, const char *dest) dest_backup = NULL; if (rename_errno != ENOENT) { - error (0, rename_errno, _("cannot backup %s"), quote (dest)); + error (0, rename_errno, _("cannot backup %s"), + quoteaf (dest)); return false; } } @@ -327,7 +328,7 @@ do_link (const char *source, const char *dest) { if (unlink (dest) != 0) { - error (0, errno, _("cannot remove %s"), quote (dest)); + error (0, errno, _("cannot remove %s"), quoteaf (dest)); free (dest_backup); free (rel_source); return false; @@ -349,9 +350,9 @@ do_link (const char *source, const char *dest) if (verbose) { if (dest_backup) - printf ("%s ~ ", quote (dest_backup)); - printf ("%s %c> %s\n", quote_n (0, dest), (symbolic_link ? '-' : '='), - quote_n (1, source)); + printf ("%s ~ ", quoteaf (dest_backup)); + printf ("%s %c> %s\n", quoteaf_n (0, dest), + (symbolic_link ? '-' : '='), quoteaf_n (1, source)); } } else @@ -367,12 +368,12 @@ do_link (const char *source, const char *dest) || errno == EROFS) ? _("failed to create hard link %s") : _("failed to create hard link %s => %s"))), - quote_n (0, dest), quote_n (1, source)); + quoteaf_n (0, dest), quoteaf_n (1, source)); if (dest_backup) { if (rename (dest_backup, dest) != 0) - error (0, errno, _("cannot un-backup %s"), quote (dest)); + error (0, errno, _("cannot un-backup %s"), quoteaf (dest)); } } @@ -530,10 +531,10 @@ main (int argc, char **argv) struct stat st; if (stat (optarg, &st) != 0) error (EXIT_FAILURE, errno, _("failed to access %s"), - quote (optarg)); + quoteaf (optarg)); if (! S_ISDIR (st.st_mode)) error (EXIT_FAILURE, 0, _("target %s is not a directory"), - quote (optarg)); + quoteaf (optarg)); } target_directory = optarg; break; @@ -575,9 +576,9 @@ main (int argc, char **argv) if (n_files < 2) error (0, 0, _("missing destination file operand after %s"), - quote (file[0])); + quoteaf (file[0])); else - error (0, 0, _("extra operand %s"), quote (file[2])); + error (0, 0, _("extra operand %s"), quoteaf (file[2])); usage (EXIT_FAILURE); } } @@ -589,7 +590,7 @@ main (int argc, char **argv) target_directory = file[--n_files]; else if (2 < n_files) error (EXIT_FAILURE, 0, _("target %s is not a directory"), - quote (file[n_files - 1])); + quoteaf (file[n_files - 1])); } if (backup_suffix_string) @@ -100,7 +100,6 @@ #include "mpsort.h" #include "obstack.h" #include "quote.h" -#include "quotearg.h" #include "smack.h" #include "stat-size.h" #include "stat-time.h" @@ -2534,7 +2533,7 @@ set_exit_status (bool serious) static void file_failure (bool serious, char const *message, char const *file) { - error (0, errno, message, quote (file)); + error (0, errno, message, quoteaf (file)); set_exit_status (serious); } @@ -2601,7 +2600,7 @@ print_dir (char const *name, char const *realname, bool command_line_arg) if (visit_dir (dir_stat.st_dev, dir_stat.st_ino)) { error (0, 0, _("%s: not listing already-listed directory"), - quote (name)); + quotef (name)); closedir (dirp); set_exit_status (true); return; @@ -3109,7 +3108,7 @@ gobble_file (char const *name, enum filetype type, ino_t inode, any_has_acl |= f->acl_type != ACL_T_NONE; if (err) - error (0, errno, "%s", quote (absolute_name)); + error (0, errno, "%s", quotef (absolute_name)); } if (S_ISLNK (f->stat.st_mode) diff --git a/src/md5sum.c b/src/md5sum.c index 16163cc9e..5d4b958ee 100644 --- a/src/md5sum.c +++ b/src/md5sum.c @@ -37,7 +37,6 @@ #endif #include "error.h" #include "fadvise.h" -#include "quote.h" #include "stdio--.h" #include "xfreopen.h" @@ -483,7 +482,7 @@ digest_file (const char *filename, int *binary, unsigned char *bin_result) fp = fopen (filename, (O_BINARY && *binary ? "rb" : "r")); if (fp == NULL) { - error (0, errno, "%s", quote (filename)); + error (0, errno, "%s", quotef (filename)); return false; } } @@ -493,7 +492,7 @@ digest_file (const char *filename, int *binary, unsigned char *bin_result) err = DIGEST_STREAM (fp, bin_result); if (err) { - error (0, errno, "%s", quote (filename)); + error (0, errno, "%s", quotef (filename)); if (fp != stdin) fclose (fp); return false; @@ -501,7 +500,7 @@ digest_file (const char *filename, int *binary, unsigned char *bin_result) if (!is_stdin && fclose (fp) != 0) { - error (0, errno, "%s", quote (filename)); + error (0, errno, "%s", quotef (filename)); return false; } @@ -536,7 +535,7 @@ digest_check (const char *checkfile_name) checkfile_stream = fopen (checkfile_name, "r"); if (checkfile_stream == NULL) { - error (0, errno, "%s", quote (checkfile_name)); + error (0, errno, "%s", quotef (checkfile_name)); return false; } } @@ -554,7 +553,7 @@ digest_check (const char *checkfile_name) ++line_number; if (line_number == 0) error (EXIT_FAILURE, 0, _("%s: too many checksum lines"), - quote (checkfile_name)); + quotef (checkfile_name)); line_length = getline (&line, &line_chars_allocated, checkfile_stream); if (line_length <= 0) @@ -579,7 +578,7 @@ digest_check (const char *checkfile_name) error (0, 0, _("%s: %" PRIuMAX ": improperly formatted %s checksum line"), - quote (checkfile_name), line_number, + quotef (checkfile_name), line_number, DIGEST_TYPE_STRING); } @@ -651,13 +650,13 @@ digest_check (const char *checkfile_name) if (ferror (checkfile_stream)) { - error (0, 0, _("%s: read error"), quote (checkfile_name)); + error (0, 0, _("%s: read error"), quotef (checkfile_name)); return false; } if (!is_stdin && fclose (checkfile_stream) != 0) { - error (0, errno, "%s", quote (checkfile_name)); + error (0, errno, "%s", quotef (checkfile_name)); return false; } @@ -665,7 +664,7 @@ digest_check (const char *checkfile_name) { /* Warn if no tests are found. */ error (0, 0, _("%s: no properly formatted %s checksum lines found"), - quote (checkfile_name), DIGEST_TYPE_STRING); + quotef (checkfile_name), DIGEST_TYPE_STRING); } else { diff --git a/src/mkdir.c b/src/mkdir.c index ff51ae1e6..ef562fcde 100644 --- a/src/mkdir.c +++ b/src/mkdir.c @@ -109,7 +109,7 @@ announce_mkdir (char const *dir, void *options) { struct mkdir_options const *o = options; if (o->created_directory_format) - prog_fprintf (stdout, o->created_directory_format, quote (dir)); + prog_fprintf (stdout, o->created_directory_format, quoteaf (dir)); } /* Make ancestor directory DIR, whose last component is COMPONENT, @@ -125,7 +125,7 @@ make_ancestor (char const *dir, char const *component, void *options) if (o->set_security_context && defaultcon (dir, S_IFDIR) < 0 && ! ignorable_ctx_err (errno)) error (0, errno, _("failed to set default creation context for %s"), - quote (dir)); + quoteaf (dir)); mode_t user_wx = S_IWUSR | S_IXUSR; bool self_denying_umask = (o->umask_value & user_wx) != 0; @@ -158,7 +158,7 @@ process_dir (char *dir, struct savewd *wd, void *options) if (! o->make_ancestor_function && defaultcon (dir, S_IFDIR) < 0 && ! ignorable_ctx_err (errno)) error (0, errno, _("failed to set default creation context for %s"), - quote (dir)); + quoteaf (dir)); } int ret = (make_dir_parents (dir, wd, o->make_ancestor_function, options, @@ -178,7 +178,7 @@ process_dir (char *dir, struct savewd *wd, void *options) if (! restorecon (last_component (dir), false, false) && ! ignorable_ctx_err (errno)) error (0, errno, _("failed to restore context for %s"), - quote (dir)); + quoteaf (dir)); } return ret; diff --git a/src/mkfifo.c b/src/mkfifo.c index 090656bdd..cf460af2b 100644 --- a/src/mkfifo.c +++ b/src/mkfifo.c @@ -166,13 +166,13 @@ main (int argc, char **argv) defaultcon (argv[optind], S_IFIFO); if (mkfifo (argv[optind], newmode) != 0) { - error (0, errno, _("cannot create fifo %s"), quote (argv[optind])); + error (0, errno, _("cannot create fifo %s"), quoteaf (argv[optind])); exit_status = EXIT_FAILURE; } else if (specified_mode && lchmod (argv[optind], newmode) != 0) { error (0, errno, _("cannot set permissions of %s"), - quote (argv[optind])); + quoteaf (argv[optind])); exit_status = EXIT_FAILURE; } } diff --git a/src/mknod.c b/src/mknod.c index ffade1b7a..e06118368 100644 --- a/src/mknod.c +++ b/src/mknod.c @@ -250,7 +250,7 @@ main (int argc, char **argv) defaultcon (argv[optind], node_type); if (mknod (argv[optind], newmode | node_type, device) != 0) - error (EXIT_FAILURE, errno, "%s", quote (argv[optind])); + error (EXIT_FAILURE, errno, "%s", quotef (argv[optind])); } break; @@ -258,7 +258,7 @@ main (int argc, char **argv) if (set_security_context) defaultcon (argv[optind], S_IFIFO); if (mkfifo (argv[optind], newmode) != 0) - error (EXIT_FAILURE, errno, "%s", quote (argv[optind])); + error (EXIT_FAILURE, errno, "%s", quotef (argv[optind])); break; default: @@ -268,7 +268,7 @@ main (int argc, char **argv) if (specified_mode && lchmod (argv[optind], newmode) != 0) error (EXIT_FAILURE, errno, _("cannot set permissions of %s"), - quote (argv[optind])); + quoteaf (argv[optind])); return EXIT_SUCCESS; } @@ -29,7 +29,6 @@ #include "cp-hash.h" #include "error.h" #include "filenamecat.h" -#include "quote.h" #include "remove.h" #include "root-dev-ino.h" #include "priv-set.h" @@ -96,7 +95,7 @@ rm_option_init (struct rm_options *x) x->root_dev_ino = get_root_dev_ino (&dev_ino_buf); if (x->root_dev_ino == NULL) error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote ("/")); + quoteaf ("/")); } } @@ -153,7 +152,7 @@ target_directory_operand (char const *file) int err = (stat (file, &st) == 0 ? 0 : errno); bool is_a_dir = !err && S_ISDIR (st.st_mode); if (err && err != ENOENT) - error (EXIT_FAILURE, err, _("failed to access %s"), quote (file)); + error (EXIT_FAILURE, err, _("failed to access %s"), quoteaf (file)); return is_a_dir; } @@ -403,10 +402,10 @@ main (int argc, char **argv) struct stat st; if (stat (optarg, &st) != 0) error (EXIT_FAILURE, errno, _("failed to access %s"), - quote (optarg)); + quoteaf (optarg)); if (! S_ISDIR (st.st_mode)) error (EXIT_FAILURE, 0, _("target %s is not a directory"), - quote (optarg)); + quoteaf (optarg)); } target_directory = optarg; break; @@ -448,7 +447,7 @@ main (int argc, char **argv) error (0, 0, _("missing file operand")); else error (0, 0, _("missing destination file operand after %s"), - quote (file[0])); + quoteaf (file[0])); usage (EXIT_FAILURE); } @@ -460,7 +459,7 @@ main (int argc, char **argv) "and --no-target-directory (-T)")); if (2 < n_files) { - error (0, 0, _("extra operand %s"), quote (file[2])); + error (0, 0, _("extra operand %s"), quoteaf (file[2])); usage (EXIT_FAILURE); } } @@ -471,7 +470,7 @@ main (int argc, char **argv) target_directory = file[--n_files]; else if (2 < n_files) error (EXIT_FAILURE, 0, _("target %s is not a directory"), - quote (file[n_files - 1])); + quoteaf (file[n_files - 1])); } if (make_backups && x.interactive == I_ALWAYS_NO) @@ -426,7 +426,7 @@ nl_file (char const *file) stream = fopen (file, "r"); if (stream == NULL) { - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); return false; } } @@ -437,14 +437,14 @@ nl_file (char const *file) if (ferror (stream)) { - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); return false; } if (STREQ (file, "-")) clearerr (stream); /* Also clear EOF. */ else if (fclose (stream) == EOF) { - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); return false; } return true; diff --git a/src/nohup.c b/src/nohup.c index 8cdacedb8..f81d3feea 100644 --- a/src/nohup.c +++ b/src/nohup.c @@ -29,7 +29,6 @@ #include "filenamecat.h" #include "fd-reopen.h" #include "long-options.h" -#include "quote.h" #include "unistd--.h" #define PROGRAM_NAME "nohup" @@ -158,10 +157,10 @@ main (int argc, char **argv) if (out_fd < 0) { int saved_errno2 = errno; - error (0, saved_errno, _("failed to open %s"), quote (file)); + error (0, saved_errno, _("failed to open %s"), quoteaf (file)); if (in_home) error (0, saved_errno2, _("failed to open %s"), - quote (in_home)); + quoteaf (in_home)); return exit_internal_failure; } file = in_home; @@ -172,7 +171,7 @@ main (int argc, char **argv) _(ignoring_input ? N_("ignoring input and appending output to %s") : N_("appending output to %s")), - quote (file)); + quoteaf (file)); free (in_home); } @@ -227,7 +226,7 @@ main (int argc, char **argv) In other words, output the diagnostic if possible, but only if it will go to the original stderr. */ if (dup2 (saved_stderr_fd, STDERR_FILENO) == STDERR_FILENO) - error (0, saved_errno, _("failed to run command %s"), quote (*cmd)); + error (0, saved_errno, _("failed to run command %s"), quoteaf (*cmd)); return exit_status; } @@ -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", quote (input_filename)); + error (0, errno, "%s", quotef (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"), quote (input_filename)); + error (0, in_errno, _("%s: read error"), quotef (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", quote (input_filename)); + error (0, errno, "%s", quotef (input_filename)); ok = false; } @@ -1092,7 +1092,7 @@ skip (uintmax_t n_skip) else /* cannot fstat() file */ { - error (0, errno, "%s", quote (input_filename)); + error (0, errno, "%s", quotef (input_filename)); ok = false; } diff --git a/src/paste.c b/src/paste.c index fd6f033f6..5781ccd3e 100644 --- a/src/paste.c +++ b/src/paste.c @@ -43,8 +43,6 @@ #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). */ #define PROGRAM_NAME "paste" @@ -210,7 +208,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", quote (fnamptr[files_open])); + error (EXIT_FAILURE, errno, "%s", quotef (fnamptr[files_open])); else if (fileno (fileptr[files_open]) == STDIN_FILENO) opened_stdin = true; fadvise (fileptr[files_open], FADVISE_SEQUENTIAL); @@ -268,14 +266,14 @@ paste_parallel (size_t nfiles, char **fnamptr) { if (ferror (fileptr[i])) { - error (0, err, "%s", quote (fnamptr[i])); + error (0, err, "%s", quotef (fnamptr[i])); ok = false; } if (fileptr[i] == stdin) clearerr (fileptr[i]); /* Also clear EOF. */ else if (fclose (fileptr[i]) == EOF) { - error (0, errno, "%s", quote (fnamptr[i])); + error (0, errno, "%s", quotef (fnamptr[i])); ok = false; } @@ -366,7 +364,7 @@ paste_serial (size_t nfiles, char **fnamptr) fileptr = fopen (*fnamptr, "r"); if (fileptr == NULL) { - error (0, errno, "%s", quote (*fnamptr)); + error (0, errno, "%s", quotef (*fnamptr)); ok = false; continue; } @@ -412,14 +410,14 @@ paste_serial (size_t nfiles, char **fnamptr) if (ferror (fileptr)) { - error (0, saved_errno, "%s", quote (*fnamptr)); + error (0, saved_errno, "%s", quotef (*fnamptr)); ok = false; } if (is_stdin) clearerr (fileptr); /* Also clear EOF. */ else if (fclose (fileptr) == EOF) { - error (0, errno, "%s", quote (*fnamptr)); + error (0, errno, "%s", quotef (*fnamptr)); ok = false; } } diff --git a/src/pathchk.c b/src/pathchk.c index d9f3bceb6..fbd2b5132 100644 --- a/src/pathchk.c +++ b/src/pathchk.c @@ -23,7 +23,6 @@ #include "system.h" #include "error.h" #include "quote.h" -#include "quotearg.h" /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "pathchk" @@ -168,7 +167,7 @@ no_leading_hyphen (char const *file) if (p == file || p[-1] == '/') { error (0, 0, _("leading '-' in a component of file name %s"), - quote (file)); + quoteaf (file)); return false; } @@ -196,7 +195,7 @@ portable_chars_only (char const *file, size_t filelen) _("nonportable character %s in file name %s"), quotearg_n_style_mem (1, locale_quoting_style, invalid, (charlen <= MB_LEN_MAX ? charlen : 1)), - quote_n (0, file)); + quoteaf_n (0, file)); return false; } @@ -290,7 +289,7 @@ validate_file_name (char *file, bool check_basic_portability, file_exists = true; else if (errno != ENOENT || filelen == 0) { - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); return false; } } @@ -323,7 +322,7 @@ validate_file_name (char *file, bool check_basic_portability, unsigned long int len = filelen; unsigned long int maxlen = maxsize - 1; error (0, 0, _("limit %lu exceeded by length %lu of file name %s"), - maxlen, len, quote (file)); + maxlen, len, quoteaf (file)); return false; } } @@ -393,7 +392,7 @@ validate_file_name (char *file, bool check_basic_portability, default: *start = '\0'; - error (0, errno, "%s", quote (dir)); + error (0, errno, "%s", quotef (dir)); *start = c; return false; } diff --git a/src/pinky.c b/src/pinky.c index f969e5b97..14ba72ce0 100644 --- a/src/pinky.c +++ b/src/pinky.c @@ -27,7 +27,6 @@ #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). */ @@ -469,7 +468,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", quote (filename)); + error (EXIT_FAILURE, errno, "%s", quotef (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", quote (name)); + error (0, errno, "%s", quotef (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", quote (p->name)); + error (EXIT_FAILURE, errno, "%s", quotef (p->name)); if (fileno (p->fp) != STDIN_FILENO && fclose (p->fp) != 0) - error (EXIT_FAILURE, errno, "%s", quote (p->name)); + error (EXIT_FAILURE, errno, "%s", quotef (p->name)); if (!parallel_files) { @@ -520,7 +520,7 @@ swallow_file_in_memory (const char *file_name, BLOCK *block) block->start = read_file (file_name, &used_length); if (!block->start) - error (EXIT_FAILURE, errno, "%s", quote (using_stdin ? "-" : file_name)); + error (EXIT_FAILURE, errno, "%s", quotef (using_stdin ? "-" : file_name)); block->end = block->start + used_length; } @@ -2076,7 +2076,7 @@ main (int argc, char **argv) if (optind < argc) { if (! freopen (argv[optind], "w", stdout)) - error (EXIT_FAILURE, errno, "%s", quote (argv[optind])); + error (EXIT_FAILURE, errno, "%s", quotef (argv[optind])); optind++; } @@ -274,10 +274,10 @@ robust_getcwd (struct file_name *file_name) if (root_dev_ino == NULL) error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote ("/")); + quoteaf ("/")); if (stat (".", &dot_sb) < 0) - error (EXIT_FAILURE, errno, _("failed to stat %s"), quote (".")); + error (EXIT_FAILURE, errno, _("failed to stat %s"), quoteaf (".")); while (1) { diff --git a/src/readlink.c b/src/readlink.c index 2b61fda92..aba466b29 100644 --- a/src/readlink.c +++ b/src/readlink.c @@ -25,7 +25,6 @@ #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" @@ -171,7 +170,7 @@ main (int argc, char **argv) { status = EXIT_FAILURE; if (verbose) - error (0, errno, "%s", quote (fname)); + error (0, errno, "%s", quotef (fname)); } } diff --git a/src/realpath.c b/src/realpath.c index 9f8754de6..febf956d9 100644 --- a/src/realpath.c +++ b/src/realpath.c @@ -24,7 +24,6 @@ #include "system.h" #include "canonicalize.h" #include "error.h" -#include "quote.h" #include "relpath.h" /* The official name of this program (e.g., no 'g' prefix). */ @@ -143,7 +142,7 @@ isdir (const char *path) { struct stat sb; if (stat (path, &sb) != 0) - error (EXIT_FAILURE, errno, _("cannot stat %s"), quote (path)); + error (EXIT_FAILURE, errno, _("cannot stat %s"), quoteaf (path)); return S_ISDIR (sb.st_mode); } @@ -154,7 +153,7 @@ process_path (const char *fname, int can_mode) if (!can_fname) { if (verbose) - error (0, errno, "%s", quote (fname)); + error (0, errno, "%s", quotef (fname)); return false; } @@ -246,9 +245,9 @@ main (int argc, char **argv) { can_relative_to = realpath_canon (relative_to, can_mode); if (!can_relative_to) - error (EXIT_FAILURE, errno, "%s", quote (relative_to)); + error (EXIT_FAILURE, errno, "%s", quotef (relative_to)); if (need_dir && !isdir (can_relative_to)) - error (EXIT_FAILURE, ENOTDIR, "%s", quote (relative_to)); + error (EXIT_FAILURE, ENOTDIR, "%s", quotef (relative_to)); } if (relative_base == relative_to) can_relative_base = can_relative_to; @@ -256,9 +255,9 @@ main (int argc, char **argv) { char *base = realpath_canon (relative_base, can_mode); if (!base) - error (EXIT_FAILURE, errno, "%s", quote (relative_base)); + error (EXIT_FAILURE, errno, "%s", quotef (relative_base)); if (need_dir && !isdir (base)) - error (EXIT_FAILURE, ENOTDIR, "%s", quote (relative_base)); + error (EXIT_FAILURE, ENOTDIR, "%s", quotef (relative_base)); /* --relative-to is a no-op if it does not have --relative-base as a prefix */ if (path_prefix (base, can_relative_to)) diff --git a/src/remove.c b/src/remove.c index db8f993ea..63ee73ed8 100644 --- a/src/remove.c +++ b/src/remove.c @@ -25,7 +25,6 @@ #include "error.h" #include "file-type.h" #include "ignore-value.h" -#include "quote.h" #include "remove.h" #include "root-dev-ino.h" #include "write-any-file.h" @@ -256,7 +255,7 @@ prompt (FTS const *fts, FTSENT const *ent, bool is_dir, break; } - char const *quoted_name = quote (full_name); + char const *quoted_name = quoteaf (full_name); if (write_protected < 0) { @@ -372,8 +371,8 @@ excise (FTS *fts, FTSENT *ent, struct rm_options const *x, bool is_dir) if (x->verbose) { printf ((is_dir - ? _("removed directory: %s\n") - : _("removed %s\n")), quote (ent->fts_path)); + ? _("removed directory %s\n") + : _("removed %s\n")), quoteaf (ent->fts_path)); } return RM_OK; } @@ -403,7 +402,7 @@ excise (FTS *fts, FTSENT *ent, struct rm_options const *x, bool is_dir) || errno == EEXIST) && (ent->fts_errno == EPERM || ent->fts_errno == EACCES)) errno = ent->fts_errno; - error (0, errno, _("cannot remove %s"), quote (ent->fts_path)); + error (0, errno, _("cannot remove %s"), quoteaf (ent->fts_path)); mark_ancestor_dirs (ent); return RM_ERROR; } @@ -429,7 +428,7 @@ rm_fts (FTS *fts, FTSENT *ent, struct rm_options const *x) Not recursive, and it's not an empty directory (if we're removing them) so arrange to skip contents. */ int err = x->remove_empty_directories ? ENOTEMPTY : EISDIR; - error (0, err, _("cannot remove %s"), quote (ent->fts_path)); + error (0, err, _("cannot remove %s"), quoteaf (ent->fts_path)); mark_ancestor_dirs (ent); fts_skip_tree (fts, ent); return RM_ERROR; @@ -445,8 +444,8 @@ rm_fts (FTS *fts, FTSENT *ent, struct rm_options const *x) { error (0, 0, _("refusing to remove %s or %s directory: skipping %s"), - quote_n (0, "."), quote_n (1, ".."), - quote_n (2, ent->fts_path)); + quoteaf_n (0, "."), quoteaf_n (1, ".."), + quoteaf_n (2, ent->fts_path)); fts_skip_tree (fts, ent); return RM_ERROR; } @@ -503,7 +502,7 @@ rm_fts (FTS *fts, FTSENT *ent, struct rm_options const *x) { mark_ancestor_dirs (ent); error (0, 0, _("skipping %s, since it's on a different device"), - quote (ent->fts_path)); + quoteaf (ent->fts_path)); return RM_ERROR; } @@ -523,7 +522,7 @@ rm_fts (FTS *fts, FTSENT *ent, struct rm_options const *x) /* Various failures, from opendir to ENOMEM, to failure to "return" to preceding directory, can provoke this. */ error (0, ent->fts_errno, _("traversal failed: %s"), - quote (ent->fts_path)); + quotef (ent->fts_path)); fts_skip_tree (fts, ent); return RM_ERROR; @@ -531,7 +530,7 @@ rm_fts (FTS *fts, FTSENT *ent, struct rm_options const *x) error (0, 0, _("unexpected failure: fts_info=%d: %s\n" "please report to %s"), ent->fts_info, - quote (ent->fts_path), + quotef (ent->fts_path), PACKAGE_BUGREPORT); abort (); } @@ -27,8 +27,6 @@ #include "system.h" #include "argmatch.h" #include "error.h" -#include "quote.h" -#include "quotearg.h" #include "remove.h" #include "root-dev-ino.h" #include "yesno.h" @@ -118,8 +116,8 @@ diagnose_leading_hyphen (int argc, char **argv) fprintf (stderr, _("Try '%s ./%s' to remove the file %s.\n"), argv[0], - quotearg_n_style (1, shell_quoting_style, arg), - quote (arg)); + quotearg_n_style (1, shell_escape_quoting_style, arg), + quoteaf (arg)); break; } } @@ -329,7 +327,7 @@ main (int argc, char **argv) x.root_dev_ino = get_root_dev_ino (&dev_ino_buf); if (x.root_dev_ino == NULL) error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote ("/")); + quoteaf ("/")); } uintmax_t n_files = argc - optind; diff --git a/src/rmdir.c b/src/rmdir.c index 457e855e2..083d0a04e 100644 --- a/src/rmdir.c +++ b/src/rmdir.c @@ -30,7 +30,6 @@ #include "system.h" #include "error.h" #include "prog-fprintf.h" -#include "quote.h" /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "rmdir" @@ -131,7 +130,7 @@ remove_parents (char *dir) /* Give a diagnostic for each attempted removal if --verbose. */ if (verbose) - prog_fprintf (stdout, _("removing directory, %s"), quote (dir)); + prog_fprintf (stdout, _("removing directory, %s"), quoteaf (dir)); ok = (rmdir (dir) == 0); @@ -146,7 +145,7 @@ remove_parents (char *dir) { /* Barring race conditions, DIR is expected to be a directory. */ error (0, errno, _("failed to remove directory %s"), - quote (dir)); + quoteaf (dir)); } break; } @@ -230,7 +229,7 @@ main (int argc, char **argv) /* Give a diagnostic for each attempted removal if --verbose. */ if (verbose) - prog_fprintf (stdout, _("removing directory, %s"), quote (dir)); + prog_fprintf (stdout, _("removing directory, %s"), quoteaf (dir)); if (rmdir (dir) != 0) { @@ -239,7 +238,7 @@ main (int argc, char **argv) /* Here, the diagnostic is less precise, since we have no idea whether DIR is a directory. */ - error (0, errno, _("failed to remove %s"), quote (dir)); + error (0, errno, _("failed to remove %s"), quoteaf (dir)); ok = false; } else if (remove_empty_parents) diff --git a/src/runcon.c b/src/runcon.c index d5ec57958..95b434a45 100644 --- a/src/runcon.c +++ b/src/runcon.c @@ -213,7 +213,7 @@ main (int argc, char **argv) if (getfilecon (argv[optind], &file_context) == -1) error (EXIT_FAILURE, errno, _("failed to get security context of %s"), - quote (argv[optind])); + quoteaf (argv[optind])); /* compute result of process transition */ if (security_compute_create (cur_context, file_context, string_to_security_class ("process"), diff --git a/src/selinux.c b/src/selinux.c index 99b1fb0bf..6479c9392 100644 --- a/src/selinux.c +++ b/src/selinux.c @@ -26,7 +26,6 @@ #include "canonicalize.h" #include "dosname.h" #include "xfts.h" -#include "quote.h" #include "selinux.h" #if HAVE_SELINUX_SELINUX_H @@ -125,7 +124,7 @@ defaultcon (char const *path, mode_t mode) newpath = canonicalize_filename_mode (path, CAN_MISSING); if (! newpath) error (EXIT_FAILURE, errno, _("error canonicalizing %s"), - quote (path)); + quoteaf (path)); path = newpath; } @@ -298,7 +297,7 @@ restorecon (char const *path, bool recurse, bool local) newpath = canonicalize_filename_mode (path, CAN_MISSING); if (! newpath) error (EXIT_FAILURE, errno, _("error canonicalizing %s"), - quote (path)); + quoteaf (path)); } const char *ftspath[2] = { newpath ? newpath : path, NULL }; diff --git a/src/shred.c b/src/shred.c index 9c6752881..08e212a23 100644 --- a/src/shred.c +++ b/src/shred.c @@ -90,7 +90,6 @@ #include "error.h" #include "fcntl--.h" #include "human.h" -#include "quote.h" #include "randint.h" #include "randread.h" #include "stat-size.h" @@ -1082,7 +1081,7 @@ wipename (char *oldname, char const *qoldname, struct Options const *flags) char *base = last_component (newname); size_t len = base_len (base); char *dir = dir_name (newname); - char *qdir = xstrdup (quote (dir)); + char *qdir = xstrdup (quotef (dir)); bool first = true; bool ok = true; int dir_fd = -1; @@ -1302,12 +1301,12 @@ main (int argc, char **argv) randint_source = randint_all_new (random_source, SIZE_MAX); if (! randint_source) - error (EXIT_FAILURE, errno, "%s", quote (random_source)); + error (EXIT_FAILURE, errno, "%s", quotef (random_source)); atexit (clear_random_data); for (i = 0; i < n_files; i++) { - char *qname = xstrdup (quote (file[i])); + char *qname = xstrdup (quotef (file[i])); if (STREQ (file[i], "-")) { ok &= wipefd (STDOUT_FILENO, qname, randint_source, &flags); diff --git a/src/shuf.c b/src/shuf.c index d7b5a3521..507a4c64a 100644 --- a/src/shuf.c +++ b/src/shuf.c @@ -519,7 +519,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", quote (operand[0])); + error (EXIT_FAILURE, errno, "%s", quotef (operand[0])); fadvise (stdin, FADVISE_SEQUENTIAL); @@ -544,7 +544,7 @@ main (int argc, char **argv) ? SIZE_MAX : randperm_bound (head_lines, n_lines))); if (! randint_source) - error (EXIT_FAILURE, errno, "%s", quote (random_source)); + error (EXIT_FAILURE, errno, "%s", quotef (random_source)); if (use_reservoir_sampling) { @@ -566,7 +566,7 @@ main (int argc, char **argv) permutation = randperm_new (randint_source, head_lines, n_lines); if (outfile && ! freopen (outfile, "w", stdout)) - error (EXIT_FAILURE, errno, "%s", quote (outfile)); + error (EXIT_FAILURE, errno, "%s", quotef (outfile)); /* Generate output according to requested method */ if (repeat) diff --git a/src/sort.c b/src/sort.c index 3e741027c..38d817544 100644 --- a/src/sort.c +++ b/src/sort.c @@ -44,7 +44,6 @@ #include "physmem.h" #include "posixver.h" #include "quote.h" -#include "quotearg.h" #include "randread.h" #include "readtokens0.h" #include "stdio--.h" @@ -409,7 +408,7 @@ static void die (char const *message, char const *file) { error (0, errno, "%s: %s", message, - quote (file ? file : _("standard output"))); + quotef (file ? file : _("standard output"))); exit (SORT_FAILURE); } @@ -723,12 +722,12 @@ reap (pid_t pid) if (cpid < 0) error (SORT_FAILURE, errno, _("waiting for %s [-d]"), - quote (compress_program)); + quoteaf (compress_program)); else if (0 < cpid && (0 < pid || delete_proc (cpid))) { if (! WIFEXITED (status) || WEXITSTATUS (status)) error (SORT_FAILURE, 0, _("%s [-d] terminated abnormally"), - quote (compress_program)); + quoteaf (compress_program)); --nprocs; } @@ -882,7 +881,7 @@ create_temp_file (int *pfd, bool survive_fd_exhaustion) { if (! (survive_fd_exhaustion && errno == EMFILE)) error (SORT_FAILURE, errno, _("cannot create temporary file in %s"), - quote (temp_dir)); + quoteaf (temp_dir)); free (node); node = NULL; } @@ -958,7 +957,7 @@ stream_open (char const *file, char const *how) { if (file && ftruncate (STDOUT_FILENO, 0) != 0) error (SORT_FAILURE, errno, _("%s: error truncating"), - quote (file)); + quotef (file)); fp = stdout; } else @@ -1177,7 +1176,7 @@ open_temp (struct tempnode *temp) case -1: if (errno != EMFILE) error (SORT_FAILURE, errno, _("couldn't create process for %s -d"), - quote (compress_program)); + quoteaf (compress_program)); close (tempfd); errno = EMFILE; break; @@ -1249,7 +1248,7 @@ zaptemp (char const *name) cs_leave (cs); if (unlink_status != 0) - error (0, unlink_errno, _("warning: cannot remove: %s"), quote (name)); + error (0, unlink_errno, _("warning: cannot remove: %s"), quotef (name)); if (! next) temptail = pnode; free (node); @@ -4570,7 +4569,7 @@ main (int argc, char **argv) on the command-line. */ if (nfiles) { - error (0, 0, _("extra operand %s"), quote (files[0])); + error (0, 0, _("extra operand %s"), quoteaf (files[0])); fprintf (stderr, "%s\n", _("file operands cannot be combined with --files0-from")); usage (SORT_FAILURE); @@ -4583,14 +4582,14 @@ main (int argc, char **argv) stream = fopen (files_from, "r"); if (stream == NULL) error (SORT_FAILURE, errno, _("cannot open %s for reading"), - quote (files_from)); + quoteaf (files_from)); } readtokens0_init (&tok); if (! readtokens0 (stream, &tok) || fclose (stream) != 0) error (SORT_FAILURE, 0, _("cannot read file names from %s"), - quote (files_from)); + quoteaf (files_from)); if (tok.n_tok) { @@ -4603,7 +4602,7 @@ main (int argc, char **argv) if (STREQ (files[i], "-")) error (SORT_FAILURE, 0, _("when reading file names from stdin, " "no file name of %s allowed"), - quote (files[i])); + quoteaf (files[i])); else if (files[i][0] == '\0') { /* Using the standard 'filename:line-number:' prefix here is @@ -4612,13 +4611,13 @@ main (int argc, char **argv) unsigned long int file_number = i + 1; error (SORT_FAILURE, 0, _("%s:%lu: invalid zero-length file name"), - quote (files_from), file_number); + quotef (files_from), file_number); } } } else error (SORT_FAILURE, 0, _("no input from %s"), - quote (files_from)); + quoteaf (files_from)); } /* Inheritance of global options to individual keys. */ @@ -4701,7 +4700,7 @@ main (int argc, char **argv) { if (nfiles > 1) error (SORT_FAILURE, 0, _("extra operand %s not allowed with -%c"), - quote (files[1]), checkonly); + quoteaf (files[1]), checkonly); if (outfile) { diff --git a/src/split.c b/src/split.c index f16cb518e..5d6037672 100644 --- a/src/split.c +++ b/src/split.c @@ -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", quote (infile)); + error (EXIT_FAILURE, errno, "%s", quotef (infile)); size += n_read; } if (bufsize <= size && lseek (fd, - size, SEEK_CUR) < 0) - error (EXIT_FAILURE, errno, "%s", quote (infile)); + error (EXIT_FAILURE, errno, "%s", quotef (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", quote (outfile)); + error (EXIT_FAILURE, ENAMETOOLONG, "%s", quotef (outfile)); free (dir); } #endif @@ -417,19 +417,19 @@ create (const char *name) if (!filter_command) { if (verbose) - fprintf (stdout, _("creating file %s\n"), quote (name)); + fprintf (stdout, _("creating file %s\n"), quoteaf (name)); int fd = open (name, O_WRONLY | O_CREAT | O_BINARY, MODE_RW_UGO); if (fd < 0) return fd; struct stat out_stat_buf; if (fstat (fd, &out_stat_buf) != 0) - error (EXIT_FAILURE, errno, _("failed to stat %s"), quote (name)); + error (EXIT_FAILURE, errno, _("failed to stat %s"), quoteaf (name)); if (SAME_INODE (in_stat_buf, out_stat_buf)) error (EXIT_FAILURE, 0, _("%s would overwrite input; aborting"), - quote (name)); + quoteaf (name)); if (ftruncate (fd, 0) != 0) - error (EXIT_FAILURE, errno, _("%s: error truncating"), quote (name)); + error (EXIT_FAILURE, errno, _("%s: error truncating"), quotef (name)); return fd; } @@ -444,7 +444,7 @@ create (const char *name) error (EXIT_FAILURE, errno, _("failed to set FILE environment variable")); if (verbose) - fprintf (stdout, _("executing with FILE=%s\n"), quote (name)); + fprintf (stdout, _("executing with FILE=%s\n"), quotef (name)); if (pipe (fd_pair) != 0) error (EXIT_FAILURE, errno, _("failed to create pipe")); child_pid = fork (); @@ -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", quote (name)); + error (EXIT_FAILURE, errno, "%s", quotef (name)); if (fd >= 0) { if (fp == NULL && close (fd) < 0) - error (EXIT_FAILURE, errno, "%s", quote (name)); + error (EXIT_FAILURE, errno, "%s", quotef (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"), - quote (name), signame, filter_command); + quotef (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"), - quote (name), ex, filter_command); + quotef (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", quote (outfile)); + error (EXIT_FAILURE, errno, "%s", quotef (outfile)); } if (full_write (output_desc, bp, bytes) != bytes && ! ignorable (errno)) - error (EXIT_FAILURE, errno, "%s", quote (outfile)); + error (EXIT_FAILURE, errno, "%s", quotef (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", quote (infile)); + error (EXIT_FAILURE, errno, "%s", quotef (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", quote (infile)); + error (EXIT_FAILURE, errno, "%s", quotef (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", quote (infile)); + error (EXIT_FAILURE, errno, "%s", quotef (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", quote (infile)); + error (EXIT_FAILURE, errno, "%s", quotef (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", quote (infile)); + error (EXIT_FAILURE, errno, "%s", quotef (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", quote (infile)); + error (EXIT_FAILURE, errno, "%s", quotef (infile)); while (start < end) { @@ -951,14 +951,14 @@ 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", quote (infile)); + error (EXIT_FAILURE, errno, "%s", quotef (infile)); } if (n_read == 0) break; /* eof. */ n_read = MIN (n_read, end - start); if (full_write (STDOUT_FILENO, buf, n_read) != n_read && ! ignorable (errno)) - error (EXIT_FAILURE, errno, "%s", quote ("-")); + error (EXIT_FAILURE, errno, "%s", quotef ("-")); start += n_read; } } @@ -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", quote (files[i_check].of_name)); + error (EXIT_FAILURE, errno, "%s", quotef (files[i_check].of_name)); file_limit = true; @@ -1034,18 +1034,18 @@ ofile_open (of_t *files, size_t i_check, size_t nfiles) /* No more open files to close, exit with E[NM]FILE. */ if (i_reopen == i_check) error (EXIT_FAILURE, errno, "%s", - quote (files[i_check].of_name)); + quotef (files[i_check].of_name)); } if (fclose (files[i_reopen].ofile) != 0) - error (EXIT_FAILURE, errno, "%s", quote (files[i_reopen].of_name)); + error (EXIT_FAILURE, errno, "%s", quotef (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", quote (files[i_check].of_name)); + error (EXIT_FAILURE, errno, "%s", quotef (files[i_check].of_name)); files[i_check].opid = filter_pid; filter_pid = 0; } @@ -1094,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", quote (infile)); + error (EXIT_FAILURE, errno, "%s", quotef (infile)); else if (n_read == 0) break; /* eof. */ eob = buf + n_read; @@ -1142,14 +1142,14 @@ lines_rr (uintmax_t k, uintmax_t n, char *buf, size_t bufsize) && ! ignorable (errno)) { error (EXIT_FAILURE, errno, "%s", - quote (files[i_file].of_name)); + quotef (files[i_file].of_name)); } } else if (fwrite (bp, to_write, 1, files[i_file].ofile) != 1 && ! ignorable (errno)) { error (EXIT_FAILURE, errno, "%s", - quote (files[i_file].of_name)); + quotef (files[i_file].of_name)); } if (! ignorable (errno)) wrote = true; @@ -1159,7 +1159,7 @@ lines_rr (uintmax_t k, uintmax_t n, char *buf, size_t bufsize) if (fclose (files[i_file].ofile) != 0) { error (EXIT_FAILURE, errno, "%s", - quote (files[i_file].of_name)); + quotef (files[i_file].of_name)); } files[i_file].ofile = NULL; files[i_file].ofd = OFD_APPEND; @@ -1494,7 +1494,7 @@ main (int argc, char **argv) if (! STREQ (infile, "-") && fd_reopen (STDIN_FILENO, infile, O_RDONLY, 0) < 0) error (EXIT_FAILURE, errno, _("cannot open %s for reading"), - quote (infile)); + quoteaf (infile)); /* Binary I/O is safer when byte counts are used. */ if (O_BINARY && ! isatty (STDIN_FILENO)) @@ -1503,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", quote (infile)); + error (EXIT_FAILURE, errno, "%s", quotef (infile)); bool specified_buf_size = !! in_blk_size; if (! specified_buf_size) @@ -1537,7 +1537,7 @@ main (int argc, char **argv) } if (input_offset < 0) error (EXIT_FAILURE, 0, _("%s: cannot determine file size"), - quote (infile)); + quotef (infile)); /* Overflow, and sanity checking. */ if (OFF_T_MAX < n_units) { @@ -1605,7 +1605,7 @@ main (int argc, char **argv) IF_LINT (free (b)); if (close (STDIN_FILENO) != 0) - error (EXIT_FAILURE, errno, "%s", quote (infile)); + error (EXIT_FAILURE, errno, "%s", quotef (infile)); closeout (NULL, output_desc, filter_pid, outfile); return EXIT_SUCCESS; diff --git a/src/stat.c b/src/stat.c index a8a8c9d64..0721457d9 100644 --- a/src/stat.c +++ b/src/stat.c @@ -733,7 +733,7 @@ out_file_context (char *pformat, size_t prefix_len, char const *filename) : lgetfilecon (filename, &scontext)) < 0) { error (0, errno, _("failed to get security context of %s"), - quote (filename)); + quoteaf (filename)); scontext = NULL; fail = true; } @@ -889,7 +889,7 @@ out_mount_point (char const *filename, char *pformat, size_t prefix_len, char *resolved = canonicalize_file_name (filename); if (!resolved) { - error (0, errno, _("failed to canonicalize %s"), quote (filename)); + error (0, errno, _("failed to canonicalize %s"), quoteaf (filename)); goto print_mount_point; } bp = find_bind_mount (resolved); @@ -979,18 +979,18 @@ print_stat (char *pformat, size_t prefix_len, unsigned int m, out_string (pformat, prefix_len, filename); break; case 'N': - out_string (pformat, prefix_len, quote (filename)); + out_string (pformat, prefix_len, quoteaf (filename)); if (S_ISLNK (statbuf->st_mode)) { char *linkname = areadlink_with_size (filename, statbuf->st_size); if (linkname == NULL) { error (0, errno, _("cannot read symbolic link %s"), - quote (filename)); + quoteaf (filename)); return true; } printf (" -> "); - out_string (pformat, prefix_len, quote (linkname)); + out_string (pformat, prefix_len, quoteaf (linkname)); free (linkname); } break; @@ -1265,14 +1265,14 @@ do_statfs (char const *filename, char const *format) if (STREQ (filename, "-")) { error (0, 0, _("using %s to denote standard input does not work" - " in file system mode"), quote (filename)); + " in file system mode"), quoteaf (filename)); return false; } if (STATFS (filename, &statfsbuf) != 0) { error (0, errno, _("cannot read file system information for %s"), - quote (filename)); + quoteaf (filename)); return false; } @@ -1303,7 +1303,7 @@ do_stat (char const *filename, char const *format, ? stat (filename, &statbuf) : lstat (filename, &statbuf)) != 0) { - error (0, errno, _("cannot stat %s"), quote (filename)); + error (0, errno, _("cannot stat %s"), quoteaf (filename)); return false; } diff --git a/src/stty.c b/src/stty.c index 2ed3939d5..c509b643e 100644 --- a/src/stty.c +++ b/src/stty.c @@ -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", quote (device_name)); + error (EXIT_FAILURE, errno, "%s", quotef (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"), - quote (device_name)); + quotef (device_name)); } else device_name = _("standard input"); if (tcgetattr (STDIN_FILENO, &mode)) - error (EXIT_FAILURE, errno, "%s", quote (device_name)); + error (EXIT_FAILURE, errno, "%s", quotef (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"), - quote_n (0, device_name), quote_n (1, arg)); + quotef_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", quote (device_name)); + error (EXIT_FAILURE, errno, "%s", quotef (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", quote (device_name)); + error (EXIT_FAILURE, errno, "%s", quotef (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"), - quote (device_name)); + quotef (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", quote (device_name)); + error (EXIT_FAILURE, errno, "%s", quotef (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", quote (device_name)); + error (EXIT_FAILURE, errno, "%s", quotef (device_name)); if (ioctl (STDIN_FILENO, TIOCSSIZE, (char *) &ttysz)) - error (EXIT_FAILURE, errno, "%s", quote (device_name)); + error (EXIT_FAILURE, errno, "%s", quotef (device_name)); return; } # endif if (ioctl (STDIN_FILENO, TIOCSWINSZ, (char *) &win)) - error (EXIT_FAILURE, errno, "%s", quote (device_name)); + error (EXIT_FAILURE, errno, "%s", quotef (device_name)); } static void @@ -1741,11 +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", quote (device_name)); + error (EXIT_FAILURE, errno, "%s", quotef (device_name)); if (!fancy) error (EXIT_FAILURE, 0, _("%s: no size information for this device"), - quote (device_name)); + quotef (device_name)); } else { @@ -27,7 +27,6 @@ #include "error.h" #include "fadvise.h" #include "human.h" -#include "quote.h" #include "safe-read.h" #include "xfreopen.h" @@ -106,7 +105,7 @@ bsd_sum_file (const char *file, int print_name) fp = fopen (file, (O_BINARY ? "rb" : "r")); if (fp == NULL) { - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); return false; } } @@ -123,7 +122,7 @@ bsd_sum_file (const char *file, int print_name) if (ferror (fp)) { - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); if (!is_stdin) fclose (fp); return false; @@ -131,7 +130,7 @@ bsd_sum_file (const char *file, int print_name) if (!is_stdin && fclose (fp) != 0) { - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); return false; } @@ -176,7 +175,7 @@ sysv_sum_file (const char *file, int print_name) fd = open (file, O_RDONLY | O_BINARY); if (fd == -1) { - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); return false; } } @@ -191,7 +190,7 @@ sysv_sum_file (const char *file, int print_name) if (bytes_read == SAFE_READ_ERROR) { - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); if (!is_stdin) close (fd); return false; @@ -204,7 +203,7 @@ sysv_sum_file (const char *file, int print_name) if (!is_stdin && close (fd) != 0) { - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); return false; } @@ -271,6 +270,6 @@ main (int argc, char **argv) ok &= sum_func (argv[optind], files_given); if (have_read_stdin && fclose (stdin) == EOF) - error (EXIT_FAILURE, errno, "%s", quote ("-")); + error (EXIT_FAILURE, errno, "%s", quotef ("-")); return ok ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/src/sync.c b/src/sync.c index 5e1dbb8c6..bae64831b 100644 --- a/src/sync.c +++ b/src/sync.c @@ -24,7 +24,6 @@ #include "system.h" #include "error.h" -#include "quote.h" /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "sync" @@ -111,7 +110,7 @@ sync_arg (enum sync_mode mode, char const *file) if (open_flags != (O_WRONLY | O_NONBLOCK)) fd = open (file, O_WRONLY | O_NONBLOCK); if (fd < 0) - error (0, rd_errno, _("error opening %s"), quote (file)); + error (0, rd_errno, _("error opening %s"), quoteaf (file)); return false; } @@ -121,7 +120,8 @@ sync_arg (enum sync_mode mode, char const *file) if (fdflags == -1 || fcntl (fd, F_SETFL, fdflags & ~O_NONBLOCK) < 0) { - error (0, errno, _("couldn't reset non-blocking mode %s"), quote (file)); + error (0, errno, _("couldn't reset non-blocking mode %s"), + quoteaf (file)); ret = false; } @@ -151,14 +151,14 @@ sync_arg (enum sync_mode mode, char const *file) if (sync_status < 0) { - error (0, errno, _("error syncing %s"), quote (file)); + error (0, errno, _("error syncing %s"), quoteaf (file)); ret = false; } } if (close (fd) < 0) { - error (0, errno, _("failed to close %s"), quote (file)); + error (0, errno, _("failed to close %s"), quoteaf (file)); ret = false; } diff --git a/src/system.h b/src/system.h index 1cd6bdb44..ded187f83 100644 --- a/src/system.h +++ b/src/system.h @@ -693,7 +693,7 @@ WARNING: Circular directory structure.\n\ This almost certainly means that you have a corrupted file system.\n\ NOTIFY YOUR SYSTEM MANAGER.\n\ The following directory is part of the cycle:\n %s\n"), \ - quote (file_name)); \ + quotef (file_name)); \ } \ while (0) @@ -731,3 +731,22 @@ is_ENOTSUP (int err) { return err == EOPNOTSUPP || (ENOTSUP != EOPNOTSUPP && err == ENOTSUP); } + + +/* How coreutils quotes filenames, to minimize use of outer quotes, + but also provide better support for copy and paste when used. */ +#include "quotearg.h" + +/* Use these to shell quote only when necessary, + when the quoted item is already delimited with colons. */ +#define quotef(arg) \ + quotearg_n_style_colon (0, shell_escape_quoting_style, arg) +#define quotef_n(n, arg) \ + quotearg_n_style_colon (n, shell_escape_quoting_style, arg) + +/* Use these when there are spaces around the file name, + in the error message. */ +#define quoteaf(arg) \ + quotearg_style (shell_escape_always_quoting_style, arg) +#define quoteaf_n(n, arg) \ + quotearg_n_style (n, shell_escape_always_quoting_style, arg) @@ -45,7 +45,6 @@ tac -r -s '.\| #include "error.h" #include "filenamecat.h" -#include "quote.h" #include "safe-read.h" #include "stdlib--.h" #include "xfreopen.h" @@ -220,7 +219,7 @@ tac_seekable (int input_fd, const char *file, off_t file_pos) { file_pos -= remainder; if (lseek (input_fd, file_pos, SEEK_SET) < 0) - error (0, errno, _("%s: seek failed"), quote (file)); + error (0, errno, _("%s: seek failed"), quotef (file)); } /* Scan backward, looking for end of file. This caters to proc-like @@ -230,7 +229,7 @@ tac_seekable (int input_fd, const char *file, off_t file_pos) { off_t rsize = read_size; if (lseek (input_fd, -rsize, SEEK_CUR) < 0) - error (0, errno, _("%s: seek failed"), quote (file)); + error (0, errno, _("%s: seek failed"), quotef (file)); file_pos -= read_size; } @@ -248,7 +247,7 @@ tac_seekable (int input_fd, const char *file, off_t file_pos) if (saved_record_size == SAFE_READ_ERROR) { - error (0, errno, _("%s: read error"), quote (file)); + error (0, errno, _("%s: read error"), quotef (file)); return false; } @@ -340,7 +339,7 @@ tac_seekable (int input_fd, const char *file, off_t file_pos) file_pos = 0; } if (lseek (input_fd, file_pos, SEEK_SET) < 0) - error (0, errno, _("%s: seek failed"), quote (file)); + error (0, errno, _("%s: seek failed"), quotef (file)); /* Shift the pending record data right to make room for the new. The source and destination regions probably overlap. */ @@ -354,7 +353,7 @@ tac_seekable (int input_fd, const char *file, off_t file_pos) if (safe_read (input_fd, G_buffer, read_size) != read_size) { - error (0, errno, _("%s: read error"), quote (file)); + error (0, errno, _("%s: read error"), quotef (file)); return false; } } @@ -456,7 +455,7 @@ temp_stream (FILE **fp, char **file_name) if (fd < 0) { error (0, errno, _("failed to create temporary file in %s"), - quote (tempdir)); + quoteaf (tempdir)); goto Reset; } @@ -464,7 +463,7 @@ temp_stream (FILE **fp, char **file_name) if (! tmp_fp) { error (0, errno, _("failed to open %s for writing"), - quote (tempfile)); + quoteaf (tempfile)); close (fd); unlink (tempfile); Reset: @@ -481,7 +480,7 @@ temp_stream (FILE **fp, char **file_name) || ftruncate (fileno (tmp_fp), 0) < 0) { error (0, errno, _("failed to rewind stream for %s"), - quote (tempfile)); + quoteaf (tempfile)); return false; } } @@ -511,13 +510,13 @@ copy_to_temp (FILE **g_tmp, char **g_tempfile, int input_fd, char const *file) break; if (bytes_read == SAFE_READ_ERROR) { - error (0, errno, _("%s: read error"), quote (file)); + error (0, errno, _("%s: read error"), quotef (file)); goto Fail; } if (fwrite (G_buffer, 1, bytes_read, fp) != bytes_read) { - error (0, errno, _("%s: write error"), quote (file_name)); + error (0, errno, _("%s: write error"), quotef (file_name)); goto Fail; } @@ -529,7 +528,7 @@ copy_to_temp (FILE **g_tmp, char **g_tempfile, int input_fd, char const *file) if (fflush (fp) != 0) { - error (0, errno, _("%s: write error"), quote (file_name)); + error (0, errno, _("%s: write error"), quotef (file_name)); goto Fail; } @@ -584,7 +583,7 @@ tac_file (const char *filename) if (fd < 0) { error (0, errno, _("failed to open %s for reading"), - quote (filename)); + quoteaf (filename)); return false; } } @@ -597,7 +596,7 @@ tac_file (const char *filename) if (!is_stdin && close (fd) != 0) { - error (0, errno, _("%s: read error"), quote (filename)); + error (0, errno, _("%s: read error"), quotef (filename)); ok = false; } return ok; diff --git a/src/tail.c b/src/tail.c index 6c5dd3a9d..223c8f839 100644 --- a/src/tail.c +++ b/src/tail.c @@ -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)"), quote (filename), fd); + error (0, errno, _("closing %s (fd=%d)"), quoteaf (filename), fd); } } @@ -383,7 +383,7 @@ xwrite_stdout (char const *buffer, size_t n_bytes) { clearerr (stdout); /* To avoid redundant close_stdout diagnostic. */ error (EXIT_FAILURE, errno, _("error writing %s"), - quote ("standard output")); + quoteaf ("standard output")); } } @@ -408,7 +408,7 @@ dump_remainder (const char *pretty_filename, int fd, uintmax_t n_bytes) { if (errno != EAGAIN) error (EXIT_FAILURE, errno, _("error reading %s"), - quote (pretty_filename)); + quoteaf (pretty_filename)); break; } if (bytes_read == 0) @@ -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"), - quote (filename), s); + quotef (filename), s); break; case SEEK_CUR: error (0, errno, _("%s: cannot seek to relative offset %s"), - quote (filename), s); + quotef (filename), s); break; case SEEK_END: error (0, errno, _("%s: cannot seek to end-relative offset %s"), - quote (filename), s); + quotef (filename), s); break; default: abort (); @@ -495,7 +495,7 @@ file_lines (const char *pretty_filename, int fd, uintmax_t n_lines, bytes_read = safe_read (fd, buffer, bytes_read); if (bytes_read == SAFE_READ_ERROR) { - error (0, errno, _("error reading %s"), quote (pretty_filename)); + error (0, errno, _("error reading %s"), quoteaf (pretty_filename)); return false; } *read_pos = pos + bytes_read; @@ -544,7 +544,7 @@ file_lines (const char *pretty_filename, int fd, uintmax_t n_lines, bytes_read = safe_read (fd, buffer, BUFSIZ); if (bytes_read == SAFE_READ_ERROR) { - error (0, errno, _("error reading %s"), quote (pretty_filename)); + error (0, errno, _("error reading %s"), quoteaf (pretty_filename)); return false; } @@ -637,7 +637,7 @@ pipe_lines (const char *pretty_filename, int fd, uintmax_t n_lines, if (n_read == SAFE_READ_ERROR) { - error (0, errno, _("error reading %s"), quote (pretty_filename)); + error (0, errno, _("error reading %s"), quoteaf (pretty_filename)); ok = false; goto free_lbuffers; } @@ -765,7 +765,7 @@ pipe_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes, if (n_read == SAFE_READ_ERROR) { - error (0, errno, _("error reading %s"), quote (pretty_filename)); + error (0, errno, _("error reading %s"), quoteaf (pretty_filename)); ok = false; goto free_cbuffers; } @@ -813,7 +813,7 @@ start_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes, return -1; if (bytes_read == SAFE_READ_ERROR) { - error (0, errno, _("error reading %s"), quote (pretty_filename)); + error (0, errno, _("error reading %s"), quoteaf (pretty_filename)); return 1; } *read_pos += bytes_read; @@ -850,7 +850,7 @@ start_lines (const char *pretty_filename, int fd, uintmax_t n_lines, return -1; if (bytes_read == SAFE_READ_ERROR) /* error */ { - error (0, errno, _("error reading %s"), quote (pretty_filename)); + error (0, errno, _("error reading %s"), quoteaf (pretty_filename)); return 1; } @@ -891,7 +891,7 @@ fremote (int fd, const char *name) is open on a pipe. Treat that like a remote file. */ if (errno != ENOSYS) error (0, errno, _("cannot determine location of %s. " - "reverting to polling"), quote (name)); + "reverting to polling"), quoteaf (name)); } else { @@ -952,7 +952,7 @@ recheck (struct File_spec *f, bool blocking) f->ignore = true; error (0, 0, _("%s has been replaced with a symbolic link. " - "giving up on this name"), quote (pretty_name (f))); + "giving up on this name"), quoteaf (pretty_name (f))); } else if (fd == -1 || fstat (fd, &new_stats) < 0) { @@ -967,7 +967,7 @@ recheck (struct File_spec *f, bool blocking) be seen to be the same file (dev/ino). Otherwise, tail prints the entire contents of the file when it becomes readable. */ error (0, f->errnum, _("%s has become inaccessible"), - quote (pretty_name (f))); + quoteaf (pretty_name (f))); } else { @@ -975,7 +975,7 @@ recheck (struct File_spec *f, bool blocking) } } else if (prev_errnum != errno) - error (0, errno, "%s", quote (pretty_name (f))); + error (0, errno, "%s", quotef (pretty_name (f))); } else if (!IS_TAILABLE_FILE_TYPE (new_stats.st_mode)) { @@ -983,7 +983,7 @@ recheck (struct File_spec *f, bool blocking) f->errnum = -1; error (0, 0, _("%s has been replaced with an untailable file;\ giving up on this name"), - quote (pretty_name (f))); + quoteaf (pretty_name (f))); f->ignore = true; } else if (!disable_inotify && fremote (fd, pretty_name (f))) @@ -991,7 +991,7 @@ recheck (struct File_spec *f, bool blocking) ok = false; f->errnum = -1; error (0, 0, _("%s has been replaced with a remote file. " - "giving up on this name"), quote (pretty_name (f))); + "giving up on this name"), quoteaf (pretty_name (f))); f->ignore = true; f->remote = true; } @@ -1011,7 +1011,7 @@ recheck (struct File_spec *f, bool blocking) { new_file = true; assert (f->fd == -1); - error (0, 0, _("%s has become accessible"), quote (pretty_name (f))); + error (0, 0, _("%s has become accessible"), quoteaf (pretty_name (f))); } else if (f->fd == -1) { @@ -1024,7 +1024,7 @@ recheck (struct File_spec *f, bool blocking) error (0, 0, _("%s has appeared; following new file"), - quote (pretty_name (f))); + quoteaf (pretty_name (f))); } else if (f->ino != new_stats.st_ino || f->dev != new_stats.st_dev) { @@ -1034,7 +1034,7 @@ recheck (struct File_spec *f, bool blocking) error (0, 0, _("%s has been replaced; following new file"), - quote (pretty_name (f))); + quoteaf (pretty_name (f))); /* Close the old one. */ close_fd (f->fd, pretty_name (f)); @@ -1151,7 +1151,7 @@ tail_forever (struct File_spec *f, size_t n_files, double sleep_interval) else error (EXIT_FAILURE, errno, _("%s: cannot change nonblocking mode"), - quote (name)); + quotef (name)); } else f[i].blocking = blocking; @@ -1163,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", quote (name)); + error (0, errno, "%s", quotef (name)); close (fd); /* ignore failure */ continue; } @@ -1196,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"), quote (name)); + error (0, 0, _("%s: file truncated"), quotef (name)); /* Assume the file was truncated to 0, and therefore output all "new" data. */ xlseek (fd, 0, SEEK_SET, name); @@ -1338,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"), quote (name)); + error (0, 0, _("%s: file truncated"), quotef (name)); xlseek (fspec->fd, 0, SEEK_SET, name); fspec->size = 0; } @@ -1433,7 +1433,7 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files, { if (errno != ENOSPC) /* suppress confusing error. */ error (0, errno, _("cannot watch parent directory of %s"), - quote (f[i].name)); + quoteaf (f[i].name)); else error (0, 0, _("inotify resources exhausted")); found_unwatchable_dir = true; @@ -1456,7 +1456,7 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files, break; } else if (errno != f[i].errnum) - error (0, errno, _("cannot watch %s"), quote (f[i].name)); + error (0, errno, _("cannot watch %s"), quoteaf (f[i].name)); continue; } @@ -1506,7 +1506,7 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files, && (f[i].dev != stats.st_dev || f[i].ino != stats.st_ino)) { error (0, errno, _("%s was replaced"), - quote (pretty_name (&(f[i])))); + quoteaf (pretty_name (&(f[i])))); hash_free (wd_to_name); errno = 0; @@ -1635,7 +1635,7 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files, else { /* Can get ENOENT for a dangling symlink for example. */ - error (0, errno, _("cannot watch %s"), quote (f[j].name)); + error (0, errno, _("cannot watch %s"), quoteaf (f[j].name)); } /* We'll continue below after removing the existing watch. */ } @@ -1726,7 +1726,7 @@ tail_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes, if (fstat (fd, &stats)) { - error (0, errno, _("cannot fstat %s"), quote (pretty_filename)); + error (0, errno, _("cannot fstat %s"), quoteaf (pretty_filename)); return false; } @@ -1782,7 +1782,7 @@ tail_lines (const char *pretty_filename, int fd, uintmax_t n_lines, if (fstat (fd, &stats)) { - error (0, errno, _("cannot fstat %s"), quote (pretty_filename)); + error (0, errno, _("cannot fstat %s"), quoteaf (pretty_filename)); return false; } @@ -1881,7 +1881,7 @@ tail_file (struct File_spec *f, uintmax_t n_units) f->dev = 0; } error (0, errno, _("cannot open %s for reading"), - quote (pretty_name (f))); + quoteaf (pretty_name (f))); ok = false; } else @@ -1906,13 +1906,14 @@ tail_file (struct File_spec *f, uintmax_t n_units) { ok = false; f->errnum = errno; - error (0, errno, _("error reading %s"), quote (pretty_name (f))); + error (0, errno, _("error reading %s"), + quoteaf (pretty_name (f))); } else if (!IS_TAILABLE_FILE_TYPE (stats.st_mode)) { error (0, 0, _("%s: cannot follow end of this type of file;\ giving up on this name"), - quote (pretty_name (f))); + quotef (pretty_name (f))); ok = false; f->errnum = -1; f->ignore = true; @@ -1936,7 +1937,8 @@ tail_file (struct File_spec *f, uintmax_t n_units) { if (!is_stdin && close (fd)) { - error (0, errno, _("error reading %s"), quote (pretty_name (f))); + error (0, errno, _("error reading %s"), + quoteaf (pretty_name (f))); ok = false; } } @@ -2258,7 +2260,7 @@ main (int argc, char **argv) /* When following by name, there must be a name. */ if (found_hyphen && follow_mode == Follow_name) - error (EXIT_FAILURE, 0, _("cannot follow %s by name"), quote ("-")); + error (EXIT_FAILURE, 0, _("cannot follow %s by name"), quoteaf ("-")); /* When following forever, warn if any file is '-'. This is only a warning, since tail's output (before a failing seek, @@ -25,7 +25,6 @@ #include "argmatch.h" #include "error.h" #include "fadvise.h" -#include "quote.h" #include "stdio--.h" #include "xfreopen.h" @@ -219,7 +218,7 @@ tee_files (int nfiles, char **files) { error (output_error == output_error_exit || output_error == output_error_exit_nopipe, - errno, "%s", quote (files[i])); + errno, "%s", quotef (files[i])); ok = false; } else @@ -252,7 +251,7 @@ tee_files (int nfiles, char **files) { error (output_error == output_error_exit || output_error == output_error_exit_nopipe, - w_errno, "%s", quote (files[i])); + w_errno, "%s", quotef (files[i])); } descriptors[i] = NULL; if (fail) @@ -271,7 +270,7 @@ tee_files (int nfiles, char **files) for (i = 1; i <= nfiles; i++) if (descriptors[i] && fclose (descriptors[i]) != 0) { - error (0, errno, "%s", quote (files[i])); + error (0, errno, "%s", quotef (files[i])); ok = false; } diff --git a/src/touch.c b/src/touch.c index 628610a81..7408321aa 100644 --- a/src/touch.c +++ b/src/touch.c @@ -169,7 +169,7 @@ touch (const char *file) { if (close (STDIN_FILENO) != 0) { - error (0, errno, _("failed to close %s"), quote (file)); + error (0, errno, _("failed to close %s"), quoteaf (file)); return false; } } @@ -188,13 +188,13 @@ touch (const char *file) - the file does not exist, but the parent directory is unwritable - the file exists, but it isn't writable I think it's not worth trying to distinguish them. */ - error (0, open_errno, _("cannot touch %s"), quote (file)); + error (0, open_errno, _("cannot touch %s"), quoteaf (file)); } else { if (no_create && errno == ENOENT) return true; - error (0, errno, _("setting times of %s"), quote (file)); + error (0, errno, _("setting times of %s"), quoteaf (file)); } return false; } @@ -344,7 +344,7 @@ main (int argc, char **argv) if (no_dereference ? lstat (ref_file, &ref_stats) : stat (ref_file, &ref_stats)) error (EXIT_FAILURE, errno, - _("failed to get attributes of %s"), quote (ref_file)); + _("failed to get attributes of %s"), quoteaf (ref_file)); newtime[0] = get_stat_atime (&ref_stats); newtime[1] = get_stat_mtime (&ref_stats); date_set = true; diff --git a/src/truncate.c b/src/truncate.c index c40cd6113..f49efc5e2 100644 --- a/src/truncate.c +++ b/src/truncate.c @@ -110,7 +110,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize, if ((block_mode || (rel_mode && rsize < 0)) && fstat (fd, &sb) != 0) { - error (0, errno, _("cannot fstat %s"), quote (fname)); + error (0, errno, _("cannot fstat %s"), quoteaf (fname)); return false; } if (block_mode) @@ -122,7 +122,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize, _("overflow in %" PRIdMAX " * %" PRIdMAX " byte blocks for file %s"), (intmax_t) ssize, (intmax_t) blksize, - quote (fname)); + quoteaf (fname)); return false; } ssize *= blksize; @@ -144,7 +144,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize, /* Sanity check. Overflow is the only reason I can think this would ever go negative. */ error (0, 0, _("%s has unusable, apparently negative size"), - quote (fname)); + quoteaf (fname)); return false; } } @@ -154,7 +154,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize, if (file_size < 0) { error (0, errno, _("cannot get the size of %s"), - quote (fname)); + quoteaf (fname)); return false; } } @@ -176,7 +176,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize, if (overflow > OFF_T_MAX) { error (0, 0, _("overflow rounding up size of file %s"), - quote (fname)); + quoteaf (fname)); return false; } nsize = overflow; @@ -186,7 +186,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize, if (ssize > OFF_T_MAX - (off_t)fsize) { error (0, 0, _("overflow extending size of file %s"), - quote (fname)); + quoteaf (fname)); return false; } nsize = fsize + ssize; @@ -200,7 +200,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize, if (ftruncate (fd, nsize) == -1) /* note updates mtime & ctime */ { error (0, errno, - _("failed to truncate %s at %" PRIdMAX " bytes"), quote (fname), + _("failed to truncate %s at %" PRIdMAX " bytes"), quoteaf (fname), (intmax_t) nsize); return false; } @@ -334,7 +334,7 @@ main (int argc, char **argv) struct stat sb; off_t file_size = -1; if (stat (ref_file, &sb) != 0) - error (EXIT_FAILURE, errno, _("cannot stat %s"), quote (ref_file)); + error (EXIT_FAILURE, errno, _("cannot stat %s"), quoteaf (ref_file)); if (usable_st_size (&sb)) file_size = sb.st_size; else @@ -356,7 +356,7 @@ main (int argc, char **argv) } if (file_size < 0) error (EXIT_FAILURE, errno, _("cannot get the size of %s"), - quote (ref_file)); + quoteaf (ref_file)); if (!got_size) size = file_size; else @@ -376,7 +376,7 @@ main (int argc, char **argv) if (!(no_create && errno == ENOENT)) { error (0, errno, _("cannot open %s for writing"), - quote (fname)); + quoteaf (fname)); errors = true; } continue; @@ -388,7 +388,7 @@ main (int argc, char **argv) errors |= !do_ftruncate (fd, fname, size, rsize, rel_mode); if (close (fd) != 0) { - error (0, errno, _("failed to close %s"), quote (fname)); + error (0, errno, _("failed to close %s"), quoteaf (fname)); errors = true; } } diff --git a/src/tsort.c b/src/tsort.c index dc9bed5e9..9a8498001 100644 --- a/src/tsort.c +++ b/src/tsort.c @@ -30,9 +30,9 @@ #include "long-options.h" #include "error.h" #include "fadvise.h" -#include "quote.h" #include "readtokens.h" #include "stdio--.h" +#include "quote.h" /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "tsort" @@ -445,7 +445,7 @@ tsort (const char *file) root = new_item (NULL); if (!is_stdin && ! freopen (file, "r", stdin)) - error (EXIT_FAILURE, errno, "%s", quote (file)); + error (EXIT_FAILURE, errno, "%s", quotef (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"), - quote (file)); + quotef (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:"), quote (file)); + error (0, 0, _("%s: input contains a loop:"), quotef (file)); ok = false; /* Print the loop and remove a relation to break it. */ @@ -532,7 +532,7 @@ tsort (const char *file) if (fclose (stdin) != 0) error (EXIT_FAILURE, errno, "%s", - is_stdin ? _("standard input") : quote (file)); + is_stdin ? _("standard input") : quotef (file)); return ok; } diff --git a/src/unexpand.c b/src/unexpand.c index 14ff84f2b..ec5fb81d8 100644 --- a/src/unexpand.c +++ b/src/unexpand.c @@ -243,14 +243,14 @@ next_file (FILE *fp) { if (ferror (fp)) { - error (0, errno, "%s", quote (prev_file)); + error (0, errno, "%s", quotef (prev_file)); exit_status = EXIT_FAILURE; } if (STREQ (prev_file, "-")) clearerr (fp); /* Also clear EOF. */ else if (fclose (fp) != 0) { - error (0, errno, "%s", quote (prev_file)); + error (0, errno, "%s", quotef (prev_file)); exit_status = EXIT_FAILURE; } } @@ -270,7 +270,7 @@ next_file (FILE *fp) fadvise (fp, FADVISE_SEQUENTIAL); return fp; } - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); exit_status = EXIT_FAILURE; } return NULL; diff --git a/src/uniq.c b/src/uniq.c index c85be6ee8..79eb40b7f 100644 --- a/src/uniq.c +++ b/src/uniq.c @@ -28,11 +28,11 @@ #include "fadvise.h" #include "hard-locale.h" #include "posixver.h" -#include "quote.h" #include "stdio--.h" #include "xmemcoll.h" #include "xstrtol.h" #include "memcasecmp.h" +#include "quote.h" /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "uniq" @@ -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", quote (infile)); + error (EXIT_FAILURE, errno, "%s", quotef (infile)); if (! (STREQ (outfile, "-") || freopen (outfile, "w", stdout))) - error (EXIT_FAILURE, errno, "%s", quote (outfile)); + error (EXIT_FAILURE, errno, "%s", quotef (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"), quote (infile)); + error (EXIT_FAILURE, 0, _("error reading %s"), quoteaf (infile)); /* stdout is handled via the atexit-invoked close_stdout function. */ diff --git a/src/unlink.c b/src/unlink.c index 0b26fd4e1..7fba45ff0 100644 --- a/src/unlink.c +++ b/src/unlink.c @@ -83,7 +83,7 @@ main (int argc, char **argv) } if (unlink (argv[optind]) != 0) - error (EXIT_FAILURE, errno, _("cannot unlink %s"), quote (argv[optind])); + error (EXIT_FAILURE, errno, _("cannot unlink %s"), quoteaf (argv[optind])); return EXIT_SUCCESS; } diff --git a/src/uptime.c b/src/uptime.c index b35fd0742..3f15b6b5f 100644 --- a/src/uptime.c +++ b/src/uptime.c @@ -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", quote (filename)); + error (EXIT_FAILURE, errno, "%s", quotef (filename)); #endif print_uptime (n_users, utmp_buf); diff --git a/src/users.c b/src/users.c index 2a66101f9..6f943891a 100644 --- a/src/users.c +++ b/src/users.c @@ -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", quote (filename)); + error (EXIT_FAILURE, errno, "%s", quotef (filename)); list_entries_users (n_users, utmp_buf); @@ -32,7 +32,6 @@ #include "fadvise.h" #include "mbchar.h" #include "physmem.h" -#include "quote.h" #include "readtokens0.h" #include "safe-read.h" #include "stat-size.h" @@ -258,7 +257,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", quote (file)); + error (0, errno, "%s", quotef (file)); ok = false; break; } @@ -274,7 +273,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", quote (file)); + error (0, errno, "%s", quotef (file)); ok = false; break; } @@ -342,7 +341,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", quote (file)); + error (0, errno, "%s", quotef (file)); ok = false; break; } @@ -463,7 +462,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", quote (file)); + error (0, errno, "%s", quotef (file)); ok = false; break; } @@ -540,7 +539,7 @@ wc_file (char const *file, struct fstatus *fstatus) int fd = open (file, O_RDONLY | O_BINARY); if (fd == -1) { - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); return false; } else @@ -548,7 +547,7 @@ wc_file (char const *file, struct fstatus *fstatus) bool ok = wc (fd, file, fstatus, 0); if (close (fd) != 0) { - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); return false; } return ok; @@ -696,7 +695,7 @@ main (int argc, char **argv) on the command-line. */ if (optind < argc) { - error (0, 0, _("extra operand %s"), quote (argv[optind])); + error (0, 0, _("extra operand %s"), quoteaf (argv[optind])); fprintf (stderr, "%s\n", _("file operands cannot be combined with --files0-from")); usage (EXIT_FAILURE); @@ -709,7 +708,7 @@ main (int argc, char **argv) stream = fopen (files_from, "r"); if (stream == NULL) error (EXIT_FAILURE, errno, _("cannot open %s for reading"), - quote (files_from)); + quoteaf (files_from)); } /* Read the file list into RAM if we can detect its size and that @@ -723,7 +722,7 @@ main (int argc, char **argv) readtokens0_init (&tok); if (! readtokens0 (stream, &tok) || fclose (stream) != 0) error (EXIT_FAILURE, 0, _("cannot read file names from %s"), - quote (files_from)); + quoteaf (files_from)); files = tok.tok; nfiles = tok.n_tok; ai = argv_iter_init_argv (files); @@ -764,7 +763,7 @@ main (int argc, char **argv) goto argv_iter_done; case AI_ERR_READ: error (0, errno, _("%s: read error"), - quote (files_from)); + quotef (files_from)); ok = false; goto argv_iter_done; case AI_ERR_MEM: @@ -779,7 +778,7 @@ main (int argc, char **argv) printf - | wc --files0-from=- */ error (0, 0, _("when reading file names from stdin, " "no file name of %s allowed"), - quote (file_name)); + quoteaf (file_name)); skip_file = true; } @@ -797,7 +796,7 @@ main (int argc, char **argv) not totally appropriate, since NUL is the separator, not NL, but it might be better than nothing. */ unsigned long int file_number = argv_iter_n_args (ai); - error (0, 0, "%s:%lu: %s", quote (files_from), + error (0, 0, "%s:%lu: %s", quotef (files_from), file_number, _("invalid zero-length file name")); } skip_file = true; @@ -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", quote (filename)); + error (EXIT_FAILURE, errno, "%s", quotef (filename)); if (short_list) list_entries_who (n_users, utmp_buf); diff --git a/tests/df/total-unprocessed.sh b/tests/df/total-unprocessed.sh index 9779471df..f15461dee 100755 --- a/tests/df/total-unprocessed.sh +++ b/tests/df/total-unprocessed.sh @@ -34,7 +34,7 @@ if test "$(df --output=fstype . | tail -n1)" != '-'; then fi cat <<\EOF > exp || framework_failure_ -df: '_does_not_exist_': No such file or directory +df: _does_not_exist_: No such file or directory EOF # Ensure that df writes the error message also in the following case. diff --git a/tests/du/files0-from-dir.sh b/tests/du/files0-from-dir.sh index 4d7e90cf5..67b9f6231 100755 --- a/tests/du/files0-from-dir.sh +++ b/tests/du/files0-from-dir.sh @@ -29,10 +29,10 @@ cat dir > /dev/null && skip_ "cat dir/ succeeds" for prog in du wc; do $prog --files0-from=dir > /dev/null 2>err && fail=1 - printf "$prog: 'dir':\n" > exp || fail=1 + printf "$prog: dir:\n" > exp || fail=1 # The diagnostic string is usually "Is a directory" (ENOTDIR), # but accept a different string or errno value. - sed "s/'dir':.*/'dir':/" err > k; mv k err + sed "s/dir:.*/dir:/" err > k; mv k err compare exp err || fail=1 done diff --git a/tests/du/files0-from.pl b/tests/du/files0-from.pl index f0177a2d0..3854059f0 100755 --- a/tests/du/files0-from.pl +++ b/tests/du/files0-from.pl @@ -53,12 +53,12 @@ my @Tests = # one NUL ['nul-1', '--files0-from=-', '<', {IN=>"\0"}, {EXIT=>1}, - {ERR => "$prog: '-':1: invalid zero-length file name\n"}], + {ERR => "$prog: -:1: invalid zero-length file name\n"}], # two NULs ['nul-2', '--files0-from=-', '<', {IN=>"\0\0"}, {EXIT=>1}, - {ERR => "$prog: '-':1: invalid zero-length file name\n" - . "$prog: '-':2: invalid zero-length file name\n"}], + {ERR => "$prog: -:1: invalid zero-length file name\n" + . "$prog: -:2: invalid zero-length file name\n"}], # one file name, no NUL ['1', '--files0-from=-', '<', @@ -84,7 +84,7 @@ my @Tests = ['zero-len', '--files0-from=-', '<', {IN=>{f=>"\0g\0"}}, {AUX=>{g=>''}}, {OUT=>"0\tg\n"}, {OUT_SUBST=>'s/^\d+/0/'}, - {ERR => "$prog: '-':1: invalid zero-length file name\n"}, {EXIT=>1} ], + {ERR => "$prog: -:1: invalid zero-length file name\n"}, {EXIT=>1} ], ); my $save_temps = $ENV{DEBUG}; diff --git a/tests/du/move-dir-while-traversing.sh b/tests/du/move-dir-while-traversing.sh index 33db58e44..67bb34580 100755 --- a/tests/du/move-dir-while-traversing.sh +++ b/tests/du/move-dir-while-traversing.sh @@ -92,7 +92,7 @@ du -a $t d2 2> err test $? = 1 || fail=1 # check for the new diagnostic -printf "du: fts_read failed: '$t/3/a/b': No such file or directory\n" > exp \ +printf "du: fts_read failed: $t/3/a/b: No such file or directory\n" > exp \ || fail=1 compare exp err || fail=1 diff --git a/tests/ln/hard-to-sym.sh b/tests/ln/hard-to-sym.sh index edcee6600..0e63074a2 100755 --- a/tests/ln/hard-to-sym.sh +++ b/tests/ln/hard-to-sym.sh @@ -70,12 +70,12 @@ mkdir d || framework_failure_ ln -s d link-to-dir || framework_failure_ ln -L link-to-dir hard-to-dir-link 2>err && fail=1 case $(cat err) in - *": 'link-to-dir': hard link not allowed for directory"*) ;; + *": link-to-dir: hard link not allowed for directory"*) ;; *) fail=1 ;; esac ln -P link-to-dir/ hard-to-dir-link 2>err && fail=1 case $(cat err) in - *": 'link-to-dir/': hard link not allowed for directory"*) ;; + *": link-to-dir/: hard link not allowed for directory"*) ;; *) fail=1 ;; esac ln -P link-to-dir hard-to-dir-link || fail=1 diff --git a/tests/misc/dircolors.pl b/tests/misc/dircolors.pl index 2ef6228de..2e6f27d88 100755 --- a/tests/misc/dircolors.pl +++ b/tests/misc/dircolors.pl @@ -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" diff --git a/tests/misc/ls-misc.pl b/tests/misc/ls-misc.pl index f88c7a8ea..007e25787 100755 --- a/tests/misc/ls-misc.pl +++ b/tests/misc/ls-misc.pl @@ -235,7 +235,7 @@ my @Tests = {POST => sub {unlink 'd/s' or die "d/s: $!\n"; rmdir 'd' or die "d: $!\n"; restore_ls_colors; }}, - {ERR => "ls: cannot access d/s: No such file or directory\n"}, + {ERR => "ls: cannot access 'd/s': No such file or directory\n"}, {EXIT => 1} ], # Related to the above fix, is this case where @@ -289,7 +289,7 @@ my @Tests = # From Stéphane Chazelas. ['no-a-isdir-b', 'no-dir d', {OUT => "d:\n"}, - {ERR => "ls: cannot access no-dir: No such file or directory\n"}, + {ERR => "ls: cannot access 'no-dir': No such file or directory\n"}, $mkdir, $rmdir, {EXIT => 2}], ['recursive-2', '-R d', {OUT => "d:\ne\n\nd/e:\n"}, $mkdir2, $rmdir2], @@ -327,8 +327,8 @@ my @Tests = # at least one of which is a nonempty directory. ['multi-arg-U1', '-U1 d no-such', {OUT => "d:\nf\n"}, - {ERR_SUBST=>'s/ch:.*/ch:/'}, - {ERR => "$prog: cannot access no-such:\n"}, + {ERR_SUBST=>"s/ch':.*/ch':/"}, + {ERR => "$prog: cannot access 'no-such':\n"}, $mkdir_reg, $rmdir_reg, {EXIT => 2}, diff --git a/tests/misc/md5sum.pl b/tests/misc/md5sum.pl index c99658213..ad1896d53 100755 --- a/tests/misc/md5sum.pl +++ b/tests/misc/md5sum.pl @@ -92,7 +92,7 @@ my @Tests = . "invalid\n" }}, {AUX=> {f=> 'foo'}}, {OUT=>"f: FAILED\nf: FAILED\n"}, - {ERR=>"md5sum: 'f.md5': 3: " + {ERR=>"md5sum: f.md5: 3: " . "improperly formatted MD5 checksum line\n" . "md5sum: WARNING: 1 line is improperly formatted\n" . "md5sum: WARNING: 2 computed checksums did NOT match\n"}, @@ -102,7 +102,7 @@ my @Tests = # sha1sum accept BSD format. ['check-bsd', '--check', {IN=> {'f.sha1' => "SHA1 (f) = $degenerate\n"}}, {AUX=> {f=> ''}}, - {ERR=>"md5sum: 'f.sha1': no properly formatted " + {ERR=>"md5sum: f.sha1: no properly formatted " . "MD5 checksum lines found\n"}, {EXIT=> 1}], ['check-bsd2', '--check', {IN=> {'f.md5' => "MD5 (f) = $degenerate\n"}}, @@ -112,7 +112,7 @@ my @Tests = {AUX=> {f=> 'bar'}}, {EXIT=> 1}], ['check-openssl', '--check', {IN=> {'f.sha1' => "SHA1(f)= $degenerate\n"}}, {AUX=> {f=> ''}}, - {ERR=>"md5sum: 'f.sha1': no properly formatted " + {ERR=>"md5sum: f.sha1: no properly formatted " . "MD5 checksum lines found\n"}, {EXIT=> 1}], ['check-openssl2', '--check', {IN=> {'f.md5' => "MD5(f)= $degenerate\n"}}, @@ -121,7 +121,7 @@ my @Tests = {IN=> {'f.md5' => "MD5(f)= $degenerate\n"}}, {AUX=> {f=> 'bar'}}, {EXIT=> 1}], ['bsd-segv', '--check', {IN=> {'z' => "MD5 ("}}, {EXIT=> 1}, - {ERR=> "$prog: 'z': no properly formatted MD5 checksum lines found\n"}], + {ERR=> "$prog: z: no properly formatted MD5 checksum lines found\n"}], # Ensure that when there's a NUL byte among the checksum hex digits # we detect the invalid formatting and don't even open the file. @@ -129,7 +129,7 @@ my @Tests = # h: FAILED # md5sum: WARNING: 1 of 1 computed checksum did NOT match ['nul-in-cksum', '--check', {IN=> {'h'=>("\0"x32)." h\n"}}, {EXIT=> 1}, - {ERR=> "$prog: 'h': no properly formatted MD5 checksum lines found\n"}], + {ERR=> "$prog: h: no properly formatted MD5 checksum lines found\n"}], ); # Insert the '--text' argument for each test. diff --git a/tests/misc/readlink-fp-loop.sh b/tests/misc/readlink-fp-loop.sh index d3e1a1eaf..50ada55e8 100755 --- a/tests/misc/readlink-fp-loop.sh +++ b/tests/misc/readlink-fp-loop.sh @@ -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 diff --git a/tests/misc/sha1sum.pl b/tests/misc/sha1sum.pl index b58a7f4a1..de923b636 100755 --- a/tests/misc/sha1sum.pl +++ b/tests/misc/sha1sum.pl @@ -53,7 +53,7 @@ my @Tests = # md5sum accept BSD format. ['check-bsd', '--check', {IN=> {'f.md5' => "MD5 (f) = $sha_degenerate\n"}}, {AUX=> {f=> ''}}, - {ERR=>"sha1sum: 'f.md5': no properly formatted " + {ERR=>"sha1sum: f.md5: no properly formatted " . "SHA1 checksum lines found\n"}, {EXIT=> 1}], ['check-bsd2', '--check', @@ -65,7 +65,7 @@ my @Tests = ['check-openssl', '--check', {IN=> {'f.md5' => "MD5(f)= $sha_degenerate\n"}}, {AUX=> {f=> ''}}, - {ERR=>"sha1sum: 'f.md5': no properly formatted " + {ERR=>"sha1sum: f.md5: no properly formatted " . "SHA1 checksum lines found\n"}, {EXIT=> 1}], ['check-openssl2', '--check', @@ -75,7 +75,7 @@ my @Tests = {IN=> {'f.sha1' => "SHA1(f)= $sha_degenerate\n"}}, {AUX=> {f=> 'bar'}}, {EXIT=> 1}], ['bsd-segv', '--check', {IN=> {'z' => "SHA1 ("}}, {EXIT=> 1}, - {ERR=> "$prog: 'z': no properly formatted SHA1 checksum lines found\n"}], + {ERR=> "$prog: z: no properly formatted SHA1 checksum lines found\n"}], ); # Insert the '--text' argument for each test. diff --git a/tests/misc/shred-passes.sh b/tests/misc/shred-passes.sh index ddf788b05..64216fd8a 100755 --- a/tests/misc/shred-passes.sh +++ b/tests/misc/shred-passes.sh @@ -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 diff --git a/tests/misc/sort-files0-from.pl b/tests/misc/sort-files0-from.pl index 6773309d1..63c5bb3e4 100755 --- a/tests/misc/sort-files0-from.pl +++ b/tests/misc/sort-files0-from.pl @@ -55,14 +55,14 @@ my @Tests = # one NUL ['nul-1', '--files0-from=-', '<', {IN=>"\0"}, {EXIT=>2}, - {ERR => "$prog: '-':1: invalid zero-length file name\n"}], + {ERR => "$prog: -:1: invalid zero-length file name\n"}], # two NULs # Note that the behavior here differs from 'wc' in that the # first zero-length file name is treated as fatal, so there # is only one line of diagnostic output. ['nul-2', '--files0-from=-', '<', {IN=>"\0\0"}, {EXIT=>2}, - {ERR => "$prog: '-':1: invalid zero-length file name\n"}], + {ERR => "$prog: -:1: invalid zero-length file name\n"}], # one file name, no NUL ['1', '--files0-from=-', '<', @@ -86,7 +86,7 @@ my @Tests = # should be no output on STDOUT. ['zero-len', '--files0-from=-', '<', {IN=>{f=>"\0g\0"}}, {AUX=>{g=>''}}, - {ERR => "$prog: '-':1: invalid zero-length file name\n"}, {EXIT=>2} ], + {ERR => "$prog: -:1: invalid zero-length file name\n"}, {EXIT=>2} ], ); my $save_temps = $ENV{DEBUG}; diff --git a/tests/misc/sort.pl b/tests/misc/sort.pl index 012d8b94e..f6a222c2c 100755 --- a/tests/misc/sort.pl +++ b/tests/misc/sort.pl @@ -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"}], diff --git a/tests/misc/tsort.pl b/tests/misc/tsort.pl index 60f22c43c..4d04866ad 100755 --- a/tests/misc/tsort.pl +++ b/tests/misc/tsort.pl @@ -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}, diff --git a/tests/misc/wc-files0-from.pl b/tests/misc/wc-files0-from.pl index 519587be6..cae3fc225 100755 --- a/tests/misc/wc-files0-from.pl +++ b/tests/misc/wc-files0-from.pl @@ -53,13 +53,13 @@ my @Tests = # one NUL ['nul-1', '--files0-from=-', '<', {IN=>"\0"}, {EXIT=>1}, - {ERR => "$prog: '-':1: invalid zero-length file name\n"}], + {ERR => "$prog: -:1: invalid zero-length file name\n"}], # two NULs ['nul-2', '--files0-from=-', '<', {IN=>"\0\0"}, {EXIT=>1}, {OUT=>"0 0 0 total\n"}, - {ERR => "$prog: '-':1: invalid zero-length file name\n" - . "$prog: '-':2: invalid zero-length file name\n"}], + {ERR => "$prog: -:1: invalid zero-length file name\n" + . "$prog: -:2: invalid zero-length file name\n"}], # one file name, no NUL ['1', '--files0-from=-', '<', @@ -83,7 +83,7 @@ my @Tests = ['zero-len', '--files0-from=-', '<', {IN=>{f=>"\0g\0"}}, {AUX=>{g=>''}}, {OUT=>"0 0 0 g\n0 0 0 total\n"}, - {ERR => "$prog: '-':1: invalid zero-length file name\n"}, {EXIT=>1} ], + {ERR => "$prog: -:1: invalid zero-length file name\n"}, {EXIT=>1} ], ); my $save_temps = $ENV{DEBUG}; diff --git a/tests/rm/d-1.sh b/tests/rm/d-1.sh index 43b753ebc..bde8c695c 100755 --- a/tests/rm/d-1.sh +++ b/tests/rm/d-1.sh @@ -25,7 +25,7 @@ mkdir a || framework_failure_ rm --verbose --dir a b > out || fail=1 cat <<\EOF > exp || framework_failure_ -removed directory: 'a' +removed directory 'a' removed 'b' EOF diff --git a/tests/rm/d-3.sh b/tests/rm/d-3.sh index af39da38b..1200ca459 100755 --- a/tests/rm/d-3.sh +++ b/tests/rm/d-3.sh @@ -28,7 +28,7 @@ printf "%s" \ > exp.err || framework_failure_ printf "%s\n" \ - "removed directory: 'd'" \ + "removed directory 'd'" \ > exp || framework_failure_ compare exp out || fail=1 diff --git a/tests/rm/r-1.sh b/tests/rm/r-1.sh index 21564c6a5..2a14110a3 100755 --- a/tests/rm/r-1.sh +++ b/tests/rm/r-1.sh @@ -23,8 +23,8 @@ mkdir a a/a || framework_failure_ > b || framework_failure_ cat <<\EOF > exp || framework_failure_ -removed directory: 'a/a' -removed directory: 'a' +removed directory 'a/a' +removed directory 'a' removed 'b' EOF diff --git a/tests/rm/r-2.sh b/tests/rm/r-2.sh index a99bdbf4b..a6616f648 100755 --- a/tests/rm/r-2.sh +++ b/tests/rm/r-2.sh @@ -25,8 +25,8 @@ mkdir t t/a t/a/b || framework_failure_ # FIXME: if this fails, it's a framework failure cat <<\EOF | sort > t/E || framework_failure_ -removed directory: 't/a' -removed directory: 't/a/b' +removed directory 't/a' +removed directory 't/a/b' removed 't/a/b/g' removed 't/a/f' EOF diff --git a/tests/rm/v-slash.sh b/tests/rm/v-slash.sh index 5cabb0bc6..5a5d401d5 100755 --- a/tests/rm/v-slash.sh +++ b/tests/rm/v-slash.sh @@ -26,7 +26,7 @@ touch a/x || framework_failure_ rm --verbose -r a/// > out || fail=1 cat <<\EOF > exp || fail=1 removed 'a/x' -removed directory: 'a/' +removed directory 'a/' EOF compare exp out || fail=1 diff --git a/tests/split/l-chunk.sh b/tests/split/l-chunk.sh index c97b3b562..c4e55685b 100755 --- a/tests/split/l-chunk.sh +++ b/tests/split/l-chunk.sh @@ -24,7 +24,7 @@ echo "split: invalid number of chunks: '1o'" > exp split -n l/1o 2>err && fail=1 compare exp err || fail=1 -echo "split: '-': cannot determine file size" > exp +echo "split: -: cannot determine file size" > exp echo | split -n l/1 2>err && fail=1 compare exp err || fail=1 |