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/touch.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/touch.c')
-rw-r--r-- | src/touch.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/touch.c b/src/touch.c index 628610a81..7408321aa 100644 --- a/src/touch.c +++ b/src/touch.c @@ -169,7 +169,7 @@ touch (const char *file) { if (close (STDIN_FILENO) != 0) { - error (0, errno, _("failed to close %s"), quote (file)); + error (0, errno, _("failed to close %s"), quoteaf (file)); return false; } } @@ -188,13 +188,13 @@ touch (const char *file) - the file does not exist, but the parent directory is unwritable - the file exists, but it isn't writable I think it's not worth trying to distinguish them. */ - error (0, open_errno, _("cannot touch %s"), quote (file)); + error (0, open_errno, _("cannot touch %s"), quoteaf (file)); } else { if (no_create && errno == ENOENT) return true; - error (0, errno, _("setting times of %s"), quote (file)); + error (0, errno, _("setting times of %s"), quoteaf (file)); } return false; } @@ -344,7 +344,7 @@ main (int argc, char **argv) if (no_dereference ? lstat (ref_file, &ref_stats) : stat (ref_file, &ref_stats)) error (EXIT_FAILURE, errno, - _("failed to get attributes of %s"), quote (ref_file)); + _("failed to get attributes of %s"), quoteaf (ref_file)); newtime[0] = get_stat_atime (&ref_stats); newtime[1] = get_stat_mtime (&ref_stats); date_set = true; |