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/chown-core.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/chown-core.c')
-rw-r--r-- | src/chown-core.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/chown-core.c b/src/chown-core.c index e8a7d5289..0e5114606 100644 --- a/src/chown-core.c +++ b/src/chown-core.c @@ -26,7 +26,6 @@ #include "chown-core.h" #include "error.h" #include "ignore-value.h" -#include "quote.h" #include "root-dev-ino.h" #include "xfts.h" @@ -145,7 +144,7 @@ describe_change (const char *file, enum Change_status changed, if (changed == CH_NOT_APPLIED) { printf (_("neither symbolic link %s nor referent has been changed\n"), - quote (file)); + quoteaf (file)); return; } @@ -185,7 +184,7 @@ describe_change (const char *file, enum Change_status changed, abort (); } - printf (fmt, quote (file), old_spec, spec); + printf (fmt, quoteaf (file), old_spec, spec); free (old_spec); free (spec); @@ -323,20 +322,20 @@ change_file_owner (FTS *fts, FTSENT *ent, } if (! chopt->force_silent) error (0, ent->fts_errno, _("cannot access %s"), - quote (file_full_name)); + quoteaf (file_full_name)); ok = false; break; case FTS_ERR: if (! chopt->force_silent) - error (0, ent->fts_errno, "%s", quote (file_full_name)); + error (0, ent->fts_errno, "%s", quotef (file_full_name)); ok = false; break; case FTS_DNR: if (! chopt->force_silent) error (0, ent->fts_errno, _("cannot read directory %s"), - quote (file_full_name)); + quoteaf (file_full_name)); ok = false; break; @@ -377,7 +376,7 @@ change_file_owner (FTS *fts, FTSENT *ent, { if (! chopt->force_silent) error (0, errno, _("cannot dereference %s"), - quote (file_full_name)); + quoteaf (file_full_name)); ok = false; } @@ -466,7 +465,7 @@ change_file_owner (FTS *fts, FTSENT *ent, error (0, errno, (uid != (uid_t) -1 ? _("changing ownership of %s") : _("changing group of %s")), - quote (file_full_name)); + quoteaf (file_full_name)); } if (chopt->verbosity != V_off) |