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/stty.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/stty.c')
-rw-r--r-- | src/stty.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/stty.c b/src/stty.c index 2ed3939d5..c509b643e 100644 --- a/src/stty.c +++ b/src/stty.c @@ -1169,17 +1169,17 @@ main (int argc, char **argv) int fdflags; device_name = file_name; if (fd_reopen (STDIN_FILENO, device_name, O_RDONLY | O_NONBLOCK, 0) < 0) - error (EXIT_FAILURE, errno, "%s", quote (device_name)); + error (EXIT_FAILURE, errno, "%s", quotef (device_name)); if ((fdflags = fcntl (STDIN_FILENO, F_GETFL)) == -1 || fcntl (STDIN_FILENO, F_SETFL, fdflags & ~O_NONBLOCK) < 0) error (EXIT_FAILURE, errno, _("%s: couldn't reset non-blocking mode"), - quote (device_name)); + quotef (device_name)); } else device_name = _("standard input"); if (tcgetattr (STDIN_FILENO, &mode)) - error (EXIT_FAILURE, errno, "%s", quote (device_name)); + error (EXIT_FAILURE, errno, "%s", quotef (device_name)); if (verbose_output || recoverable_output || noargs) { @@ -1281,7 +1281,7 @@ main (int argc, char **argv) if (ioctl (STDIN_FILENO, TIOCEXT, &val) != 0) { error (EXIT_FAILURE, errno, _("%s: error setting %s"), - quote_n (0, device_name), quote_n (1, arg)); + quotef_n (0, device_name), quote_n (1, arg)); } } #endif @@ -1362,7 +1362,7 @@ main (int argc, char **argv) static struct termios new_mode; if (tcsetattr (STDIN_FILENO, TCSADRAIN, &mode)) - error (EXIT_FAILURE, errno, "%s", quote (device_name)); + error (EXIT_FAILURE, errno, "%s", quotef (device_name)); /* POSIX (according to Zlotnick's book) tcsetattr returns zero if it performs *any* of the requested operations. This means it @@ -1372,7 +1372,7 @@ main (int argc, char **argv) compare them to the requested ones. */ if (tcgetattr (STDIN_FILENO, &new_mode)) - error (EXIT_FAILURE, errno, "%s", quote (device_name)); + error (EXIT_FAILURE, errno, "%s", quotef (device_name)); /* Normally, one shouldn't use memcmp to compare structures that may have 'holes' containing uninitialized data, but we have been @@ -1399,7 +1399,7 @@ main (int argc, char **argv) { error (EXIT_FAILURE, 0, _("%s: unable to perform all requested operations"), - quote (device_name)); + quotef (device_name)); #ifdef TESTING { size_t i; @@ -1679,7 +1679,7 @@ set_window_size (int rows, int cols, char const *device_name) if (get_win_size (STDIN_FILENO, &win)) { if (errno != EINVAL) - error (EXIT_FAILURE, errno, "%s", quote (device_name)); + error (EXIT_FAILURE, errno, "%s", quotef (device_name)); memset (&win, 0, sizeof (win)); } @@ -1721,16 +1721,16 @@ set_window_size (int rows, int cols, char const *device_name) win.ws_col = 1; if (ioctl (STDIN_FILENO, TIOCSWINSZ, (char *) &win)) - error (EXIT_FAILURE, errno, "%s", quote (device_name)); + error (EXIT_FAILURE, errno, "%s", quotef (device_name)); if (ioctl (STDIN_FILENO, TIOCSSIZE, (char *) &ttysz)) - error (EXIT_FAILURE, errno, "%s", quote (device_name)); + error (EXIT_FAILURE, errno, "%s", quotef (device_name)); return; } # endif if (ioctl (STDIN_FILENO, TIOCSWINSZ, (char *) &win)) - error (EXIT_FAILURE, errno, "%s", quote (device_name)); + error (EXIT_FAILURE, errno, "%s", quotef (device_name)); } static void @@ -1741,11 +1741,11 @@ display_window_size (bool fancy, char const *device_name) if (get_win_size (STDIN_FILENO, &win)) { if (errno != EINVAL) - error (EXIT_FAILURE, errno, "%s", quote (device_name)); + error (EXIT_FAILURE, errno, "%s", quotef (device_name)); if (!fancy) error (EXIT_FAILURE, 0, _("%s: no size information for this device"), - quote (device_name)); + quotef (device_name)); } else { |