diff options
author | Pádraig Brady <P@draigBrady.com> | 2015-11-01 18:53:26 +0000 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2015-11-04 23:30:14 +0000 |
commit | 08e8fd7e38f2dae7c69c54eb22d508b6517e66e5 (patch) | |
tree | 63d021e305cd93bea445f9484fe8b3446dda2c3d /src/chmod.c | |
parent | 1e8f9afac53a628dbc64e62bea53eb2da29c47fa (diff) | |
download | coreutils-08e8fd7e38f2dae7c69c54eb22d508b6517e66e5.tar.xz |
all: avoid quoting file names when possible
Quote file names using the "shell-escape" or "shell-escape-always"
methods, which quote as appropriate for most shells,
and better support copy and paste of presented names.
The "always" variant is used when the file name is
embedded in an error message with surrounding spaces.
* cfg.mk (sc_error_shell_quotes): A new syntax check rule
to suggest quotef() where appropriate.
(sc_error_shell_always_quotes): Likewise for quoteaf().
* src/system.h (quotef): A new define to apply shell quoting
when needed. I.E. when shell character or ':' is present.
(quoteaf): Likewise, but always quote.
* src/*.c: Use quotef() and quoteaf() rather than quote()
where appropriate.
* tests/: Adjust accordingly.
Diffstat (limited to 'src/chmod.c')
-rw-r--r-- | src/chmod.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/chmod.c b/src/chmod.c index 988ba7269..4c952b363 100644 --- a/src/chmod.c +++ b/src/chmod.c @@ -124,7 +124,7 @@ mode_changed (int dir_fd, char const *file, char const *file_full_name, { if (! force_silent) error (0, errno, _("getting new attributes of %s"), - quote (file_full_name)); + quoteaf (file_full_name)); return false; } @@ -148,7 +148,7 @@ describe_change (const char *file, mode_t old_mode, mode_t mode, if (changed == CH_NOT_APPLIED) { printf (_("neither symbolic link %s nor referent has been changed\n"), - quote (file)); + quoteaf (file)); return; } @@ -168,13 +168,13 @@ describe_change (const char *file, mode_t old_mode, mode_t mode, break; case CH_NO_CHANGE_REQUESTED: fmt = _("mode of %s retained as %04lo (%s)\n"); - printf (fmt, quote (file), + printf (fmt, quoteaf (file), (unsigned long int) (mode & CHMOD_MODE_BITS), &perms[1]); return; default: abort (); } - printf (fmt, quote (file), + printf (fmt, quoteaf (file), (unsigned long int) (old_mode & CHMOD_MODE_BITS), &old_perms[1], (unsigned long int) (mode & CHMOD_MODE_BITS), &perms[1]); } @@ -215,27 +215,27 @@ process_file (FTS *fts, FTSENT *ent) } if (! force_silent) error (0, ent->fts_errno, _("cannot access %s"), - quote (file_full_name)); + quoteaf (file_full_name)); ok = false; break; case FTS_ERR: if (! force_silent) - error (0, ent->fts_errno, "%s", quote (file_full_name)); + error (0, ent->fts_errno, "%s", quotef (file_full_name)); ok = false; break; case FTS_DNR: if (! force_silent) error (0, ent->fts_errno, _("cannot read directory %s"), - quote (file_full_name)); + quoteaf (file_full_name)); ok = false; break; case FTS_SLNONE: if (! force_silent) error (0, 0, _("cannot operate on dangling symlink %s"), - quote (file_full_name)); + quoteaf (file_full_name)); ok = false; break; @@ -275,7 +275,7 @@ process_file (FTS *fts, FTSENT *ent) { if (! force_silent) error (0, errno, _("changing permissions of %s"), - quote (file_full_name)); + quoteaf (file_full_name)); ok = false; } } @@ -311,7 +311,7 @@ process_file (FTS *fts, FTSENT *ent) new_perms[10] = naively_expected_perms[10] = '\0'; error (0, 0, _("%s: new permissions are %s, not %s"), - quote (file_full_name), + quotef (file_full_name), new_perms + 1, naively_expected_perms + 1); ok = false; } @@ -536,7 +536,7 @@ main (int argc, char **argv) change = mode_create_from_ref (reference_file); if (!change) error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote (reference_file)); + quoteaf (reference_file)); } else { @@ -555,7 +555,7 @@ main (int argc, char **argv) root_dev_ino = get_root_dev_ino (&dev_ino_buf); if (root_dev_ino == NULL) error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote ("/")); + quoteaf ("/")); } else { |