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]' \
{ \
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)
#include "system.h"
#include "error.h"
#include "fadvise.h"
-#include "xstrtol.h"
#include "quote.h"
+#include "xstrtol.h"
#include "xdectoint.h"
#include "xfreopen.h"
{
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);
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;
#include "error.h"
#include "fadvise.h"
#include "full-write.h"
-#include "quote.h"
#include "safe-read.h"
#include "xfreopen.h"
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;
}
else
{
error (0, errno, _("cannot do ioctl on %s"),
- quote (infile));
+ quoteaf (infile));
newlines2 = newlines;
return false;
}
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;
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;
}
if (fstat (input_desc, &stat_buf) < 0)
{
- error (0, errno, "%s", quote (infile));
+ error (0, errno, "%s", quotef (infile));
ok = false;
goto contin;
}
&& 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;
}
contin:
if (!STREQ (infile, "-") && close (input_desc) < 0)
{
- error (0, errno, "%s", quote (infile));
+ error (0, errno, "%s", quotef (infile));
ok = false;
}
}
if (status < 0 && errno != ENODATA)
{
error (0, errno, _("failed to get security context of %s"),
- quote (file));
+ quoteaf (file));
return 1;
}
if (file_context == NULL)
{
error (0, 0, _("can't apply partial context to unlabeled file %s"),
- quote (file));
+ quoteaf (file));
return 1;
}
{
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));
}
}
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;
{
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;
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;
}
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
{
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. */
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);
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;
{
if (! force_silent)
error (0, errno, _("getting new attributes of %s"),
- quote (file_full_name));
+ quoteaf (file_full_name));
return false;
}
if (changed == CH_NOT_APPLIED)
{
printf (_("neither symbolic link %s nor referent has been changed\n"),
- quote (file));
+ quoteaf (file));
return;
}
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]);
}
}
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;
{
if (! force_silent)
error (0, errno, _("changing permissions of %s"),
- quote (file_full_name));
+ quoteaf (file_full_name));
ok = false;
}
}
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;
}
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
{
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
{
#include "chown-core.h"
#include "error.h"
#include "ignore-value.h"
-#include "quote.h"
#include "root-dev-ino.h"
#include "xfts.h"
if (changed == CH_NOT_APPLIED)
{
printf (_("neither symbolic link %s nor referent has been changed\n"),
- quote (file));
+ quoteaf (file));
return;
}
abort ();
}
- printf (fmt, quote (file), old_spec, spec);
+ printf (fmt, quoteaf (file), old_spec, spec);
free (old_spec);
free (spec);
}
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;
{
if (! chopt->force_silent)
error (0, errno, _("cannot dereference %s"),
- quote (file_full_name));
+ quoteaf (file_full_name));
ok = false;
}
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)
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;
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;
"), stdout);
printf (_("\
--skip-chdir do not change working directory to %s\n\
-"), quote ("/"));
+"), quoteaf ("/"));
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
if (! is_oldroot && skip_chdir)
{
error (0, 0, _("option --skip-chdir only permitted if NEWROOT is old %s"),
- quote ("/"));
+ quoteaf ("/"));
usage (EXIT_CANCELED);
}
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"));
#include <stdint.h>
#include "system.h"
#include "fadvise.h"
-#include "quote.h"
#include "xfreopen.h"
#ifdef CRCTAB
fp = fopen (file, (O_BINARY ? "rb" : "r"));
if (fp == NULL)
{
- error (0, errno, "%s", quote (file));
+ error (0, errno, "%s", quotef (file));
return false;
}
}
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];
if (ferror (fp))
{
- error (0, errno, "%s", quote (file));
+ error (0, errno, "%s", quotef (file));
if (!STREQ (file, "-"))
fclose (fp);
return false;
if (!STREQ (file, "-") && fclose (fp) == EOF)
{
- error (0, errno, "%s", quote (file));
+ error (0, errno, "%s", quotef (file));
return false;
}
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])
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;
}
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
if (file_end < 0)
{
- error (0, errno, _("cannot lseek %s"), quote (name));
+ error (0, errno, _("cannot lseek %s"), quoteaf (name));
return false;
}
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;
}
{
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)
{
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;
}
}
psize += csize;
else
{
- error (0, 0, _("overflow reading %s"), quote (src_name));
+ error (0, 0, _("overflow reading %s"), quoteaf (src_name));
return false;
}
}
}
error (0, errno, _("%s: failed to get extents info"),
- quote (src_name));
+ quotef (src_name));
return false;
}
{
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;
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;
}
? 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;
}
static char const *
copy_attr_quote (struct error_context *ctx _GL_UNUSED, char const *str)
{
- return quote (str);
+ return quoteaf (str);
}
static void
{
/* 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;
}
{
if (! owner_failure_ok (x))
error (0, errno, _("clearing permissions for %s"),
- quote (dst_name));
+ quoteaf (dst_name));
return -x->require_preserve;
}
}
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;
}
? 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
{
error (0, errno,
_("failed to get security context of %s"),
- quote (src_name));
+ quoteaf (src_name));
}
if (x->require_preserve_context)
return false;
{
error (0, errno,
_("failed to set default file creation context for %s"),
- quote (dst_name));
+ quoteaf (dst_name));
}
}
{
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;
}
| (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;
}
{
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;
}
{
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;
else
{
error (0, 0, _("not writing through dangling symlink %s"),
- quote (dst_name));
+ quoteaf (dst_name));
return_val = false;
goto close_src_desc;
}
/* 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;
}
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;
}
}
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;
}
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;
&& 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;
}
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;
}
|| 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 ();
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');
}
{
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);
}
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;
}
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;
}
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;
}
&& 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;
}
{
if (errno != ENOENT)
{
- error (0, errno, _("cannot stat %s"), quote (dst_name));
+ error (0, errno, _("cannot stat %s"), quoteaf (dst_name));
return false;
}
else
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;
}
{
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;
}
}
{
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;
}
}
{
error (0, 0,
_("cannot overwrite directory %s with non-directory"),
- quote (dst_name));
+ quoteaf (dst_name));
return false;
}
}
{
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;
}
}
? _("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;
}
{
if (errno != ENOENT)
{
- error (0, errno, _("cannot backup %s"), quote (dst_name));
+ error (0, errno, _("cannot backup %s"),
+ quoteaf (dst_name));
return false;
}
else
{
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));
}
}
}
{
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;
}
}
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;
}
{
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.
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;
}
}
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
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;
}
{
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;
}
if (is_ancestor (&src_sb, ancestors))
{
error (0, 0, _("cannot copy cyclic symbolic link %s"),
- quote (src_name));
+ quoteaf (src_name));
goto un_backup;
}
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;
}
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)
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;
}
}
{
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;
}
}
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;
}
}
!= 0)
{
error (0, errno, _("cannot create special file %s"),
- quote (dst_name));
+ quoteaf (dst_name));
goto un_backup;
}
}
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;
}
if (! same_link)
{
error (0, saved_errno, _("cannot create symbolic link %s"),
- quote (dst_name));
+ quoteaf (dst_name));
goto un_backup;
}
}
}
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;
}
: 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;
}
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;
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;
}
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;
{
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));
}
}
/* 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);
}
if (utimens (dst_name, timespec))
{
error (0, errno, _("failed to preserve times for %s"),
- quote (dst_name));
+ quoteaf (dst_name));
return false;
}
}
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
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;
}
}
if (src_errno)
{
error (0, src_errno, _("failed to get attributes of %s"),
- quote (src));
+ quoteaf (src));
return false;
}
if (mkdir (dir, mkdir_mode) != 0)
{
error (0, errno, _("cannot make directory %s"),
- quote (dir));
+ quoteaf (dir));
return false;
}
else
if (lstat (dir, &stats))
{
error (0, errno, _("failed to get attributes of %s"),
- quote (dir));
+ quoteaf (dir));
return false;
}
if (lchmod (dir, stats.st_mode | S_IRWXU) != 0)
{
error (0, errno, _("setting permissions for %s"),
- quote (dir));
+ quoteaf (dir));
return false;
}
}
else if (!S_ISDIR (stats.st_mode))
{
error (0, 0, _("%s exists but is not a directory"),
- quote (dir));
+ quoteaf (dir));
return false;
}
else
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
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;
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);
}
"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. */
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)
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;
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
if (! fopen_ok)
{
- error (0, fopen_errno, "%s", quote (output_filename));
+ error (0, fopen_errno, "%s", quotef (output_filename));
cleanup_fatal ();
}
bytes_written = 0;
{
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;
{
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 ();
}
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
{
#include "fadvise.h"
#include "getndelim2.h"
#include "hash.h"
-#include "quote.h"
#include "xstrndup.h"
#include "set-fields.h"
stream = fopen (file, "r");
if (stream == NULL)
{
- error (0, errno, "%s", quote (file));
+ error (0, errno, "%s", quotef (file));
return false;
}
}
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;
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));
}
}
}
if (fclose (in_stream) == EOF)
- error (EXIT_FAILURE, errno, "%s", quote (input_filename));
+ error (EXIT_FAILURE, errno, "%s", quotef (input_filename));
free (line);
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
#include "human.h"
#include "long-options.h"
#include "quote.h"
-#include "quotearg.h"
#include "verror.h"
#include "xstrtol.h"
#include "xtime.h"
{
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
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
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);
if (val == NULL)
{
- error (0, 0, _("unrecognized operand %s"), quote (name));
+ error (0, 0, _("unrecognized operand %s"),
+ quote (name));
usage (EXIT_FAILURE);
}
val++;
count = n;
else
{
- error (0, 0, _("unrecognized operand %s"), quote (name));
+ error (0, 0, _("unrecognized operand %s"),
+ quote (name));
usage (EXIT_FAILURE);
}
{
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
}
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);
{
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)
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);
}
}
- error (0, errno, _("%s: cannot seek"), quote (input_file));
+ error (0, errno, _("%s: cannot seek"), quotef (input_file));
return false;
}
}
if (!ok)
- error (EXIT_FAILURE, errno, _("setting flags for %s"), quote (name));
+ error (EXIT_FAILURE, errno, _("setting flags for %s"), quoteaf (name));
}
}
&& 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));
}
}
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);
}
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)
{
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)
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;
}
}
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))
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;
}
}
{
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;
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;
}
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);
&& (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))
{
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));
}
}
}
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;
}
}
}
else
{
- error (0, errno, "%s", quote (stat_file));
+ error (0, errno, "%s", quotef (stat_file));
exit_status = EXIT_FAILURE;
return;
}
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;
}
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;
}
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;
}
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;
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;
}
if (! STREQ (filename, "-") && freopen (filename, "r", stdin) == NULL)
{
- error (0, errno, "%s", quote (filename));
+ error (0, errno, "%s", quotef (filename));
return false;
}
if (fclose (stdin) != 0)
{
- error (0, errno, "%s", quote (filename));
+ error (0, errno, "%s", quotef (filename));
return false;
}
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)
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;
}
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;
if (errno != 0)
{
error (0, errno, _("fts_read failed: %s"),
- quote (fts->fts_path));
+ quotef (fts->fts_path));
ok = false;
}
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;
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);
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:
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;
}
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;
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"));
{
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;
}
}
fadvise (fp, FADVISE_SEQUENTIAL);
return fp;
}
- error (0, errno, "%s", quote (file));
+ error (0, errno, "%s", quotef (file));
exit_status = EXIT_FAILURE;
}
return NULL;
#include <regex.h>
#include "error.h"
#include "long-options.h"
-#include "quotearg.h"
#include "strnumcmp.h"
#include "xstrtol.h"
#include "system.h"
#include "error.h"
-#include "quote.h"
#include "save-cwd.h"
#include "xgetcwd.h"
#include "find-mount-point.h"
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;
}
}
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;
}
}
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)
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;
#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). */
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;
}
}
#include "system.h"
#include "error.h"
#include "fadvise.h"
-#include "quote.h"
#include "xdectoint.h"
#define TAB_WIDTH 8
if (istream == NULL)
{
- error (0, errno, "%s", quote (filename));
+ error (0, errno, "%s", quotef (filename));
return false;
}
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;
}
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 ();
{
clearerr (stdout); /* To avoid redundant close_stdout diagnostic. */
error (EXIT_FAILURE, errno, _("error writing %s"),
- quote ("standard output"));
+ quoteaf ("standard output"));
}
}
_(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;
{
if (errno != 0)
{
- error (0, errno, _("error reading %s"), quote (filename));
+ error (0, errno, _("error reading %s"), quoteaf (filename));
ok = false;
break;
}
{
if (errno != 0)
{
- error (0, errno, _("error reading %s"), quote (filename));
+ error (0, errno, _("error reading %s"), quoteaf (filename));
ok = false;
goto free_mem;
}
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;
}
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;
}
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;
}
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)
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)
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))
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;
}
}
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;
/* 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"));
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;
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;
}
{
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
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;
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;
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)
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
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
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))
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))
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;
}
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;
}
}
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)
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);
}
"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);
}
}
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)
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:
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;
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;
}
#include "file-set.h"
#include "hash.h"
#include "hash-triple.h"
-#include "quote.h"
#include "relpath.h"
#include "same.h"
#include "yesno.h"
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;
}
: 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;
}
if (! hard_dir_link)
{
error (0, 0, _("%s: hard link not allowed for directory"),
- quote (source));
+ quotef (source));
return false;
}
}
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;
}
}
{
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;
}
&& (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;
}
{
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;
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;
}
}
{
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;
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
|| 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));
}
}
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;
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);
}
}
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)
#include "mpsort.h"
#include "obstack.h"
#include "quote.h"
-#include "quotearg.h"
#include "smack.h"
#include "stat-size.h"
#include "stat-time.h"
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);
}
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;
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)
#endif
#include "error.h"
#include "fadvise.h"
-#include "quote.h"
#include "stdio--.h"
#include "xfreopen.h"
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;
}
}
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;
if (!is_stdin && fclose (fp) != 0)
{
- error (0, errno, "%s", quote (filename));
+ error (0, errno, "%s", quotef (filename));
return false;
}
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;
}
}
++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)
error (0, 0,
_("%s: %" PRIuMAX
": improperly formatted %s checksum line"),
- quote (checkfile_name), line_number,
+ quotef (checkfile_name), line_number,
DIGEST_TYPE_STRING);
}
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;
}
{
/* 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
{
{
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,
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;
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,
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;
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;
}
}
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;
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:
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;
}
#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"
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 ("/"));
}
}
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;
}
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;
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);
}
"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);
}
}
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)
stream = fopen (file, "r");
if (stream == NULL)
{
- error (0, errno, "%s", quote (file));
+ error (0, errno, "%s", quotef (file));
return false;
}
}
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;
#include "filenamecat.h"
#include "fd-reopen.h"
#include "long-options.h"
-#include "quote.h"
#include "unistd--.h"
#define PROGRAM_NAME "nohup"
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;
_(ignoring_input
? N_("ignoring input and appending output to %s")
: N_("appending output to %s")),
- quote (file));
+ quoteaf (file));
free (in_home);
}
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;
}
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;
}
}
{
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;
}
else /* cannot fstat() file */
{
- error (0, errno, "%s", quote (input_filename));
+ error (0, errno, "%s", quotef (input_filename));
ok = false;
}
#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"
{
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);
{
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;
}
fileptr = fopen (*fnamptr, "r");
if (fileptr == NULL)
{
- error (0, errno, "%s", quote (*fnamptr));
+ error (0, errno, "%s", quotef (*fnamptr));
ok = false;
continue;
}
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;
}
}
#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"
if (p == file || p[-1] == '/')
{
error (0, 0, _("leading '-' in a component of file name %s"),
- quote (file));
+ quoteaf (file));
return false;
}
_("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;
}
file_exists = true;
else if (errno != ENOENT || filelen == 0)
{
- error (0, errno, "%s", quote (file));
+ error (0, errno, "%s", quotef (file));
return false;
}
}
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;
}
}
default:
*start = '\0';
- error (0, errno, "%s", quote (dir));
+ error (0, errno, "%s", quotef (dir));
*start = c;
return false;
}
#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). */
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);
{
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);
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)
{
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;
}
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++;
}
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)
{
#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"
{
status = EXIT_FAILURE;
if (verbose)
- error (0, errno, "%s", quote (fname));
+ error (0, errno, "%s", quotef (fname));
}
}
#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). */
{
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);
}
if (!can_fname)
{
if (verbose)
- error (0, errno, "%s", quote (fname));
+ error (0, errno, "%s", quotef (fname));
return false;
}
{
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;
{
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))
#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"
break;
}
- char const *quoted_name = quote (full_name);
+ char const *quoted_name = quoteaf (full_name);
if (write_protected < 0)
{
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;
}
|| 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;
}
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;
{
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;
}
{
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;
}
/* 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;
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 ();
}
#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"
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;
}
}
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;
#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"
/* 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);
{
/* Barring race conditions, DIR is expected to be a directory. */
error (0, errno, _("failed to remove directory %s"),
- quote (dir));
+ quoteaf (dir));
}
break;
}
/* 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)
{
/* 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)
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"),
#include "canonicalize.h"
#include "dosname.h"
#include "xfts.h"
-#include "quote.h"
#include "selinux.h"
#if HAVE_SELINUX_SELINUX_H
newpath = canonicalize_filename_mode (path, CAN_MISSING);
if (! newpath)
error (EXIT_FAILURE, errno, _("error canonicalizing %s"),
- quote (path));
+ quoteaf (path));
path = newpath;
}
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 };
#include "error.h"
#include "fcntl--.h"
#include "human.h"
-#include "quote.h"
#include "randint.h"
#include "randread.h"
#include "stat-size.h"
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;
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);
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);
? 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)
{
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)
#include "physmem.h"
#include "posixver.h"
#include "quote.h"
-#include "quotearg.h"
#include "randread.h"
#include "readtokens0.h"
#include "stdio--.h"
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);
}
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;
}
{
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;
}
{
if (file && ftruncate (STDOUT_FILENO, 0) != 0)
error (SORT_FAILURE, errno, _("%s: error truncating"),
- quote (file));
+ quotef (file));
fp = stdout;
}
else
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;
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);
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);
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)
{
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
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. */
{
if (nfiles > 1)
error (SORT_FAILURE, 0, _("extra operand %s not allowed with -%c"),
- quote (files[1]), checkonly);
+ quoteaf (files[1]), checkonly);
if (outfile)
{
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;
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
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;
}
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 ();
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)
{
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))
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
{
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.
{
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;
{
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;
{
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)
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;
{
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. */
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)
{
{
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;
}
}
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;
/* 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;
}
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;
&& ! 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;
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;
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))
/* 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)
}
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)
{
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;
: lgetfilecon (filename, &scontext)) < 0)
{
error (0, errno, _("failed to get security context of %s"),
- quote (filename));
+ quoteaf (filename));
scontext = NULL;
fail = true;
}
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);
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;
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;
}
? 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;
}
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)
{
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
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
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
{
error (EXIT_FAILURE, 0,
_("%s: unable to perform all requested operations"),
- quote (device_name));
+ quotef (device_name));
#ifdef TESTING
{
size_t i;
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));
}
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
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
{
#include "error.h"
#include "fadvise.h"
#include "human.h"
-#include "quote.h"
#include "safe-read.h"
#include "xfreopen.h"
fp = fopen (file, (O_BINARY ? "rb" : "r"));
if (fp == NULL)
{
- error (0, errno, "%s", quote (file));
+ error (0, errno, "%s", quotef (file));
return false;
}
}
if (ferror (fp))
{
- error (0, errno, "%s", quote (file));
+ error (0, errno, "%s", quotef (file));
if (!is_stdin)
fclose (fp);
return false;
if (!is_stdin && fclose (fp) != 0)
{
- error (0, errno, "%s", quote (file));
+ error (0, errno, "%s", quotef (file));
return false;
}
fd = open (file, O_RDONLY | O_BINARY);
if (fd == -1)
{
- error (0, errno, "%s", quote (file));
+ error (0, errno, "%s", quotef (file));
return false;
}
}
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;
if (!is_stdin && close (fd) != 0)
{
- error (0, errno, "%s", quote (file));
+ error (0, errno, "%s", quotef (file));
return false;
}
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;
}
#include "system.h"
#include "error.h"
-#include "quote.h"
/* The official name of this program (e.g., no 'g' prefix). */
#define PROGRAM_NAME "sync"
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;
}
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;
}
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;
}
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)
{
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)
#include "error.h"
#include "filenamecat.h"
-#include "quote.h"
#include "safe-read.h"
#include "stdlib--.h"
#include "xfreopen.h"
{
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
{
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;
}
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;
}
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. */
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;
}
}
if (fd < 0)
{
error (0, errno, _("failed to create temporary file in %s"),
- quote (tempdir));
+ quoteaf (tempdir));
goto Reset;
}
if (! tmp_fp)
{
error (0, errno, _("failed to open %s for writing"),
- quote (tempfile));
+ quoteaf (tempfile));
close (fd);
unlink (tempfile);
Reset:
|| ftruncate (fileno (tmp_fp), 0) < 0)
{
error (0, errno, _("failed to rewind stream for %s"),
- quote (tempfile));
+ quoteaf (tempfile));
return false;
}
}
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;
}
if (fflush (fp) != 0)
{
- error (0, errno, _("%s: write error"), quote (file_name));
+ error (0, errno, _("%s: write error"), quotef (file_name));
goto Fail;
}
if (fd < 0)
{
error (0, errno, _("failed to open %s for reading"),
- quote (filename));
+ quoteaf (filename));
return false;
}
}
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;
{
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);
}
}
{
clearerr (stdout); /* To avoid redundant close_stdout diagnostic. */
error (EXIT_FAILURE, errno, _("error writing %s"),
- quote ("standard output"));
+ quoteaf ("standard output"));
}
}
{
if (errno != EAGAIN)
error (EXIT_FAILURE, errno, _("error reading %s"),
- quote (pretty_filename));
+ quoteaf (pretty_filename));
break;
}
if (bytes_read == 0)
{
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 ();
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;
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;
}
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;
}
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;
}
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;
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;
}
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
{
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)
{
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
{
}
}
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))
{
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)))
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;
}
{
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)
{
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)
{
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));
else
error (EXIT_FAILURE, errno,
_("%s: cannot change nonblocking mode"),
- quote (name));
+ quotef (name));
}
else
f[i].blocking = blocking;
{
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;
}
(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);
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;
}
{
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;
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;
}
&& (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;
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. */
}
if (fstat (fd, &stats))
{
- error (0, errno, _("cannot fstat %s"), quote (pretty_filename));
+ error (0, errno, _("cannot fstat %s"), quoteaf (pretty_filename));
return false;
}
if (fstat (fd, &stats))
{
- error (0, errno, _("cannot fstat %s"), quote (pretty_filename));
+ error (0, errno, _("cannot fstat %s"), quoteaf (pretty_filename));
return false;
}
f->dev = 0;
}
error (0, errno, _("cannot open %s for reading"),
- quote (pretty_name (f)));
+ quoteaf (pretty_name (f)));
ok = false;
}
else
{
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;
{
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;
}
}
/* 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,
#include "argmatch.h"
#include "error.h"
#include "fadvise.h"
-#include "quote.h"
#include "stdio--.h"
#include "xfreopen.h"
{
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
{
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)
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;
}
{
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;
}
}
- 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;
}
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;
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)
_("overflow in %" PRIdMAX
" * %" PRIdMAX " byte blocks for file %s"),
(intmax_t) ssize, (intmax_t) blksize,
- quote (fname));
+ quoteaf (fname));
return false;
}
ssize *= blksize;
/* 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;
}
}
if (file_size < 0)
{
error (0, errno, _("cannot get the size of %s"),
- quote (fname));
+ quoteaf (fname));
return false;
}
}
if (overflow > OFF_T_MAX)
{
error (0, 0, _("overflow rounding up size of file %s"),
- quote (fname));
+ quoteaf (fname));
return false;
}
nsize = overflow;
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;
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;
}
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
}
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
if (!(no_create && errno == ENOENT))
{
error (0, errno, _("cannot open %s for writing"),
- quote (fname));
+ quoteaf (fname));
errors = true;
}
continue;
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;
}
}
#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"
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);
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);
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. */
if (fclose (stdin) != 0)
error (EXIT_FAILURE, errno, "%s",
- is_stdin ? _("standard input") : quote (file));
+ is_stdin ? _("standard input") : quotef (file));
return ok;
}
{
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;
}
}
fadvise (fp, FADVISE_SEQUENTIAL);
return fp;
}
- error (0, errno, "%s", quote (file));
+ error (0, errno, "%s", quotef (file));
exit_status = EXIT_FAILURE;
}
return NULL;
#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"
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);
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. */
}
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;
}
#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);
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);
#include "fadvise.h"
#include "mbchar.h"
#include "physmem.h"
-#include "quote.h"
#include "readtokens0.h"
#include "safe-read.h"
#include "stat-size.h"
{
if (bytes_read == SAFE_READ_ERROR)
{
- error (0, errno, "%s", quote (file));
+ error (0, errno, "%s", quotef (file));
ok = false;
break;
}
{
if (bytes_read == SAFE_READ_ERROR)
{
- error (0, errno, "%s", quote (file));
+ error (0, errno, "%s", quotef (file));
ok = false;
break;
}
# endif
if (bytes_read == SAFE_READ_ERROR)
{
- error (0, errno, "%s", quote (file));
+ error (0, errno, "%s", quotef (file));
ok = false;
break;
}
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;
}
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
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;
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);
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
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);
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:
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;
}
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;
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);
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.
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
# 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=-', '<',
['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};
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
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
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"
{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
# 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],
# 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},
. "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"},
# 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"}},
{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"}},
{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.
# 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.
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_
# 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
# 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',
['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',
{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.
# 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
# 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
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
# 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=-', '<',
# 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};
# 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 =
(
["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"}],
(
['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"}],
# 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},
# 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=-', '<',
['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};
rm --verbose --dir a b > out || fail=1
cat <<\EOF > exp || framework_failure_
-removed directory: 'a'
+removed directory 'a'
removed 'b'
EOF
> exp.err || framework_failure_
printf "%s\n" \
- "removed directory: 'd'" \
+ "removed directory 'd'" \
> exp || framework_failure_
compare exp out || fail=1
> 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
# 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
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
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