Fix things so `mkdir -p' can create very deep directories, e.g.,
authorJim Meyering <jim@meyering.net>
Sat, 28 Sep 2002 07:51:17 +0000 (07:51 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 28 Sep 2002 07:51:17 +0000 (07:51 +0000)
mkdir -p $(perl -e 'print "a/" x 40000') now works.

(main): For --parents (-p), call make_path with the
entire directory name, so we don't ever require that file operations
like stat or chmod be performed on the entire command line argument.

src/mkdir.c

index 5df9c18..382d802 100644 (file)
@@ -149,13 +149,11 @@ main (int argc, char **argv)
 
       if (create_parents)
        {
-         char *parents = dir_name (argv[optind]);
-         fail = make_path (parents, parent_mode, parent_mode,
+         char *dir = argv[optind];
+         fail = make_path (dir, newmode, parent_mode,
                            -1, -1, 1, verbose_fmt_string);
-         free (parents);
        }
-
-      if (fail == 0)
+      else
        {
          const char *dir = argv[optind];
          int dir_created;