summaryrefslogtreecommitdiff
path: root/src/rmdir.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1998-07-26 00:29:30 +0000
committerJim Meyering <jim@meyering.net>1998-07-26 00:29:30 +0000
commit613f0e187f77bdcd691aeae165bd4f5f031bb05c (patch)
tree4fc6b9dde6e027904d718e0ff19c6a7003e5b8f6 /src/rmdir.c
parentca6da4ffcec162b7cf3558a4a54aefe0f3478154 (diff)
downloadcoreutils-613f0e187f77bdcd691aeae165bd4f5f031bb05c.tar.xz
(main): rmdir fails with EEXIST on some systems.
Handle that, so --ignore-fail-on-non-empty works. (EEXIST): Define to zero if not defined. (ENOTEMPTY): Likewise.
Diffstat (limited to 'src/rmdir.c')
-rw-r--r--src/rmdir.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/rmdir.c b/src/rmdir.c
index dfa737ef2..f50849c71 100644
--- a/src/rmdir.c
+++ b/src/rmdir.c
@@ -31,6 +31,14 @@
#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);