From 08e8fd7e38f2dae7c69c54eb22d508b6517e66e5 Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Sun, 1 Nov 2015 18:53:26 +0000 Subject: 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. --- src/chgrp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/chgrp.c') diff --git a/src/chgrp.c b/src/chgrp.c index eb1887e60..c07270cc9 100644 --- a/src/chgrp.c +++ b/src/chgrp.c @@ -89,7 +89,8 @@ parse_group (const char *name) unsigned long int tmp; if (! (xstrtoul (name, NULL, 10, &tmp, "") == LONGINT_OK && tmp <= GID_T_MAX)) - error (EXIT_FAILURE, 0, _("invalid group: %s"), quote (name)); + error (EXIT_FAILURE, 0, _("invalid group: %s"), + quote (name)); gid = tmp; } endgrent (); /* Save a file descriptor. */ @@ -285,7 +286,7 @@ main (int argc, char **argv) struct stat ref_stats; if (stat (reference_file, &ref_stats)) error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote (reference_file)); + quoteaf (reference_file)); gid = ref_stats.st_gid; chopt.group_name = gid_to_name (ref_stats.st_gid); @@ -303,7 +304,7 @@ main (int argc, char **argv) chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf); if (chopt.root_dev_ino == NULL) error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote ("/")); + quoteaf ("/")); } bit_flags |= FTS_DEFER_STAT; -- cgit v1.2.3-54-g00ecf