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/paste.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/paste.c')
-rw-r--r-- | src/paste.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/paste.c b/src/paste.c index fd6f033f6..5781ccd3e 100644 --- a/src/paste.c +++ b/src/paste.c @@ -43,8 +43,6 @@ #include "system.h" #include "error.h" #include "fadvise.h" -#include "quote.h" -#include "quotearg.h" /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "paste" @@ -210,7 +208,7 @@ paste_parallel (size_t nfiles, char **fnamptr) { fileptr[files_open] = fopen (fnamptr[files_open], "r"); if (fileptr[files_open] == NULL) - error (EXIT_FAILURE, errno, "%s", quote (fnamptr[files_open])); + error (EXIT_FAILURE, errno, "%s", quotef (fnamptr[files_open])); else if (fileno (fileptr[files_open]) == STDIN_FILENO) opened_stdin = true; fadvise (fileptr[files_open], FADVISE_SEQUENTIAL); @@ -268,14 +266,14 @@ paste_parallel (size_t nfiles, char **fnamptr) { if (ferror (fileptr[i])) { - error (0, err, "%s", quote (fnamptr[i])); + error (0, err, "%s", quotef (fnamptr[i])); ok = false; } if (fileptr[i] == stdin) clearerr (fileptr[i]); /* Also clear EOF. */ else if (fclose (fileptr[i]) == EOF) { - error (0, errno, "%s", quote (fnamptr[i])); + error (0, errno, "%s", quotef (fnamptr[i])); ok = false; } @@ -366,7 +364,7 @@ paste_serial (size_t nfiles, char **fnamptr) fileptr = fopen (*fnamptr, "r"); if (fileptr == NULL) { - error (0, errno, "%s", quote (*fnamptr)); + error (0, errno, "%s", quotef (*fnamptr)); ok = false; continue; } @@ -412,14 +410,14 @@ paste_serial (size_t nfiles, char **fnamptr) if (ferror (fileptr)) { - error (0, saved_errno, "%s", quote (*fnamptr)); + error (0, saved_errno, "%s", quotef (*fnamptr)); ok = false; } if (is_stdin) clearerr (fileptr); /* Also clear EOF. */ else if (fclose (fileptr) == EOF) { - error (0, errno, "%s", quote (*fnamptr)); + error (0, errno, "%s", quotef (*fnamptr)); ok = false; } } |