From: Ben Gras Date: Mon, 10 Oct 2005 09:02:47 +0000 (+0000) Subject: Make mkdir -p "a/./b" work (with ".") X-Git-Url: http://zhaoyanbai.com/repos/man.dig.html?a=commitdiff_plain;h=1f497fe7077b8227a274ec3e87993adb46228299;p=minix.git Make mkdir -p "a/./b" work (with ".") --- diff --git a/commands/simple/mkdir.c b/commands/simple/mkdir.c index 9044966a1..9f837b528 100755 --- a/commands/simple/mkdir.c +++ b/commands/simple/mkdir.c @@ -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);