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/mv.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/mv.c')
-rw-r--r-- | src/mv.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -29,7 +29,6 @@ #include "cp-hash.h" #include "error.h" #include "filenamecat.h" -#include "quote.h" #include "remove.h" #include "root-dev-ino.h" #include "priv-set.h" @@ -96,7 +95,7 @@ rm_option_init (struct rm_options *x) x->root_dev_ino = get_root_dev_ino (&dev_ino_buf); if (x->root_dev_ino == NULL) error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote ("/")); + quoteaf ("/")); } } @@ -153,7 +152,7 @@ target_directory_operand (char const *file) int err = (stat (file, &st) == 0 ? 0 : errno); bool is_a_dir = !err && S_ISDIR (st.st_mode); if (err && err != ENOENT) - error (EXIT_FAILURE, err, _("failed to access %s"), quote (file)); + error (EXIT_FAILURE, err, _("failed to access %s"), quoteaf (file)); return is_a_dir; } @@ -403,10 +402,10 @@ main (int argc, char **argv) struct stat st; if (stat (optarg, &st) != 0) error (EXIT_FAILURE, errno, _("failed to access %s"), - quote (optarg)); + quoteaf (optarg)); if (! S_ISDIR (st.st_mode)) error (EXIT_FAILURE, 0, _("target %s is not a directory"), - quote (optarg)); + quoteaf (optarg)); } target_directory = optarg; break; @@ -448,7 +447,7 @@ main (int argc, char **argv) error (0, 0, _("missing file operand")); else error (0, 0, _("missing destination file operand after %s"), - quote (file[0])); + quoteaf (file[0])); usage (EXIT_FAILURE); } @@ -460,7 +459,7 @@ main (int argc, char **argv) "and --no-target-directory (-T)")); if (2 < n_files) { - error (0, 0, _("extra operand %s"), quote (file[2])); + error (0, 0, _("extra operand %s"), quoteaf (file[2])); usage (EXIT_FAILURE); } } @@ -471,7 +470,7 @@ main (int argc, char **argv) target_directory = file[--n_files]; else if (2 < n_files) error (EXIT_FAILURE, 0, _("target %s is not a directory"), - quote (file[n_files - 1])); + quoteaf (file[n_files - 1])); } if (make_backups && x.interactive == I_ALWAYS_NO) |