summaryrefslogtreecommitdiff
path: root/src/mkdir.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/mkdir.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/mkdir.c')
-rw-r--r--src/mkdir.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/mkdir.c b/src/mkdir.c
index ff51ae1e6..ef562fcde 100644
--- a/src/mkdir.c
+++ b/src/mkdir.c
@@ -109,7 +109,7 @@ announce_mkdir (char const *dir, void *options)
{
struct mkdir_options const *o = options;
if (o->created_directory_format)
- prog_fprintf (stdout, o->created_directory_format, quote (dir));
+ prog_fprintf (stdout, o->created_directory_format, quoteaf (dir));
}
/* Make ancestor directory DIR, whose last component is COMPONENT,
@@ -125,7 +125,7 @@ make_ancestor (char const *dir, char const *component, void *options)
if (o->set_security_context && defaultcon (dir, S_IFDIR) < 0
&& ! ignorable_ctx_err (errno))
error (0, errno, _("failed to set default creation context for %s"),
- quote (dir));
+ quoteaf (dir));
mode_t user_wx = S_IWUSR | S_IXUSR;
bool self_denying_umask = (o->umask_value & user_wx) != 0;
@@ -158,7 +158,7 @@ process_dir (char *dir, struct savewd *wd, void *options)
if (! o->make_ancestor_function && defaultcon (dir, S_IFDIR) < 0
&& ! ignorable_ctx_err (errno))
error (0, errno, _("failed to set default creation context for %s"),
- quote (dir));
+ quoteaf (dir));
}
int ret = (make_dir_parents (dir, wd, o->make_ancestor_function, options,
@@ -178,7 +178,7 @@ process_dir (char *dir, struct savewd *wd, void *options)
if (! restorecon (last_component (dir), false, false)
&& ! ignorable_ctx_err (errno))
error (0, errno, _("failed to restore context for %s"),
- quote (dir));
+ quoteaf (dir));
}
return ret;