summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-11-18 13:36:24 +0000
committerJim Meyering <jim@meyering.net>2000-11-18 13:36:24 +0000
commitcaf54306a311557434658a82d9df4c92b10e1784 (patch)
treed6d67c5589f0834289b994b93bf2bd0a1bcf9162
parentcde06a54ea7f7bda5f7cddbb4301b29fb06f1c8b (diff)
downloadcoreutils-caf54306a311557434658a82d9df4c92b10e1784.tar.xz
(main): With --parents, remove any trailing slashes
from the argument to the final mkdir call. Required for NetBSD.
-rw-r--r--src/mkdir.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mkdir.c b/src/mkdir.c
index 398677faf..c597f35df 100644
--- a/src/mkdir.c
+++ b/src/mkdir.c
@@ -34,6 +34,8 @@
#define AUTHORS "David MacKenzie"
+void strip_trailing_slashes ();
+
/* The name this program was run with. */
char *program_name;
@@ -147,6 +149,17 @@ main (int argc, char **argv)
fail = make_path (parents, parent_mode, parent_mode,
-1, -1, 1, verbose_fmt_string);
free (parents);
+
+ /* If we're creating parent directories, then it's ok to remove
+ trailing slashes. In fact, *not* removing them would lead
+ to calling `mkdir ("dir/", mode)' for the command `mkdir -p dir/',
+ and such a call fails on NetBSD systems if `dir' doesn't already
+ exist. */
+ /* An alternate approach would be to change make_path to interpret
+ an argument with a trailing slash as if it also had a trailing
+ `.'. In fact, that would be more consistent with POSIX, so
+ FIXME: some day. */
+ strip_trailing_slashes (argv[optind]);
}
if (fail == 0)