summaryrefslogtreecommitdiff
path: root/src/stat.c
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-11-01 18:53:26 +0000
committerPádraig Brady <P@draigBrady.com>2015-11-04 23:30:14 +0000
commit08e8fd7e38f2dae7c69c54eb22d508b6517e66e5 (patch)
tree63d021e305cd93bea445f9484fe8b3446dda2c3d /src/stat.c
parent1e8f9afac53a628dbc64e62bea53eb2da29c47fa (diff)
downloadcoreutils-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/stat.c')
-rw-r--r--src/stat.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/stat.c b/src/stat.c
index a8a8c9d64..0721457d9 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -733,7 +733,7 @@ out_file_context (char *pformat, size_t prefix_len, char const *filename)
: lgetfilecon (filename, &scontext)) < 0)
{
error (0, errno, _("failed to get security context of %s"),
- quote (filename));
+ quoteaf (filename));
scontext = NULL;
fail = true;
}
@@ -889,7 +889,7 @@ out_mount_point (char const *filename, char *pformat, size_t prefix_len,
char *resolved = canonicalize_file_name (filename);
if (!resolved)
{
- error (0, errno, _("failed to canonicalize %s"), quote (filename));
+ error (0, errno, _("failed to canonicalize %s"), quoteaf (filename));
goto print_mount_point;
}
bp = find_bind_mount (resolved);
@@ -979,18 +979,18 @@ print_stat (char *pformat, size_t prefix_len, unsigned int m,
out_string (pformat, prefix_len, filename);
break;
case 'N':
- out_string (pformat, prefix_len, quote (filename));
+ out_string (pformat, prefix_len, quoteaf (filename));
if (S_ISLNK (statbuf->st_mode))
{
char *linkname = areadlink_with_size (filename, statbuf->st_size);
if (linkname == NULL)
{
error (0, errno, _("cannot read symbolic link %s"),
- quote (filename));
+ quoteaf (filename));
return true;
}
printf (" -> ");
- out_string (pformat, prefix_len, quote (linkname));
+ out_string (pformat, prefix_len, quoteaf (linkname));
free (linkname);
}
break;
@@ -1265,14 +1265,14 @@ do_statfs (char const *filename, char const *format)
if (STREQ (filename, "-"))
{
error (0, 0, _("using %s to denote standard input does not work"
- " in file system mode"), quote (filename));
+ " in file system mode"), quoteaf (filename));
return false;
}
if (STATFS (filename, &statfsbuf) != 0)
{
error (0, errno, _("cannot read file system information for %s"),
- quote (filename));
+ quoteaf (filename));
return false;
}
@@ -1303,7 +1303,7 @@ do_stat (char const *filename, char const *format,
? stat (filename, &statbuf)
: lstat (filename, &statbuf)) != 0)
{
- error (0, errno, _("cannot stat %s"), quote (filename));
+ error (0, errno, _("cannot stat %s"), quoteaf (filename));
return false;
}