]> Zhao Yanbai Git Server - minix.git/commitdiff
Make mkdir -p "a/./b" work (with ".")
authorBen Gras <ben@minix3.org>
Mon, 10 Oct 2005 09:02:47 +0000 (09:02 +0000)
committerBen Gras <ben@minix3.org>
Mon, 10 Oct 2005 09:02:47 +0000 (09:02 +0000)
commands/simple/mkdir.c

index 9044966a1f09b54c7bb05000955958a092ff330b..9f837b5281159a11244d8654943ea152ac5f01cb 100755 (executable)
@@ -195,9 +195,11 @@ char *fordir;
   char parent[PATH_MAX + 1], *end;
 
   strcpy(parent, fordir);
-  if (!(end = strrchr(parent, '/'))) return(0);
-  *end = '\0';
-  if (!parent[0]) return(0);
+  do {
+         if (!(end = strrchr(parent, '/'))) return(0);
+         *end = '\0';
+         if (!parent[0] || !strcmp(parent, ".")) return(0);
+  } while((last = strrchr(parent, '/')) && !strcmp(last+1, "."));
 
   if (!stat(parent, &st)) {
        if (S_ISDIR(st.st_mode)) return(0);