diff -Nru fileutils-4.1.8.ORG/src/rmdir.c fileutils-4.1.8/src/rmdir.c --- fileutils-4.1.8.ORG/src/rmdir.c Sun Dec 2 17:15:54 2001 +++ fileutils-4.1.8/src/rmdir.c Thu Apr 4 12:33:04 2002 @@ -98,6 +98,27 @@ char *slash; int fail = 0; + /* All trailing slashes must be removed before the while() is entered. + Otherwise we'll try to rmdir(path) -- which we've already done + in main() and hence wind up with an ENOENT here. Example: + + address@hidden:/opt/build$ mkdir -p a/b + address@hidden:/opt/build$ rmdir -p --verbose a/b/ + rmdir: removing directory, a/b/ + rmdir: removing directory, a/b + rmdir: `a/b': No such file or directory + */ + + slash = strrchr (path, '/'); + if (slash == NULL) + return fail; + if (slash[1] == '\0') + { + while (slash > path && *slash == '/') + --slash; + slash[1] = 0; + } + while (1) { slash = strrchr (path, '/');