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/pathchk.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/pathchk.c')
-rw-r--r-- | src/pathchk.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/pathchk.c b/src/pathchk.c index d9f3bceb6..fbd2b5132 100644 --- a/src/pathchk.c +++ b/src/pathchk.c @@ -23,7 +23,6 @@ #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" @@ -168,7 +167,7 @@ no_leading_hyphen (char const *file) if (p == file || p[-1] == '/') { error (0, 0, _("leading '-' in a component of file name %s"), - quote (file)); + quoteaf (file)); return false; } @@ -196,7 +195,7 @@ portable_chars_only (char const *file, size_t filelen) _("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; } @@ -290,7 +289,7 @@ validate_file_name (char *file, bool check_basic_portability, file_exists = true; else if (errno != ENOENT || filelen == 0) { - error (0, errno, "%s", quote (file)); + error (0, errno, "%s", quotef (file)); return false; } } @@ -323,7 +322,7 @@ validate_file_name (char *file, bool check_basic_portability, 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; } } @@ -393,7 +392,7 @@ validate_file_name (char *file, bool check_basic_portability, default: *start = '\0'; - error (0, errno, "%s", quote (dir)); + error (0, errno, "%s", quotef (dir)); *start = c; return false; } |