]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(main): rmdir fails with EEXIST on some systems.
authorJim Meyering <jim@meyering.net>
Sun, 26 Jul 1998 00:29:30 +0000 (00:29 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 26 Jul 1998 00:29:30 +0000 (00:29 +0000)
Handle that, so --ignore-fail-on-non-empty works.
(EEXIST): Define to zero if not defined.
(ENOTEMPTY): Likewise.

src/rmdir.c

index dfa737ef2dd04922adc3cd97e6afaa8e1e33b1d6..f50849c71abdc3d384ca933f02fee67c20bd809a 100644 (file)
 #include "closeout.h"
 #include "error.h"
 
+#ifndef EEXIST
+# define EEXIST 0
+#endif
+
+#ifndef ENOTEMPTY
+# define ENOTEMPTY 0
+#endif
+
 void strip_trailing_slashes ();
 
 /* The name this program was run with. */
@@ -199,14 +207,17 @@ main (int argc, char **argv)
 
       if (fail)
        {
-         if (!ignore_fail_on_non_empty || errno != ENOTEMPTY)
-           {
-             error (0, errno, "%s", dir);
-             errors = 1;
-           }
+         if (ignore_fail_on_non_empty
+             && (errno == ENOTEMPTY || errno == EEXIST))
+           continue;
+
+         error (0, errno, "%s", dir);
+         errors = 1;
        }
       else if (empty_paths)
-       errors += remove_parents (dir);
+       {
+         errors += remove_parents (dir);
+       }
     }
 
   exit (errors == 0 ? EXIT_SUCCESS : EXIT_FAILURE);