aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEthan Sommer <e5ten.arch@gmail.com>2019-09-29 12:07:32 -0400
committerRob Landley <rob@landley.net>2019-10-01 10:23:08 -0500
commit44741f51a46f8e6c99ff015e0568e11d9526ac01 (patch)
treeb6780566706ad08f49dfe6f5c738a141f8fe752a
parent98d6e0cbf63822f9107a899e9443402cd64dd90d (diff)
downloadtoybox-44741f51a46f8e6c99ff015e0568e11d9526ac01.tar.gz
Add rmdir --ignore-fail-on-non-empty
-rw-r--r--toys/posix/rmdir.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/toys/posix/rmdir.c b/toys/posix/rmdir.c
index 90920ef6..d04cf0d9 100644
--- a/toys/posix/rmdir.c
+++ b/toys/posix/rmdir.c
@@ -4,7 +4,7 @@
*
* See http://opengroup.org/onlinepubs/9699919799/utilities/rmdir.html
-USE_RMDIR(NEWTOY(rmdir, "<1p", TOYFLAG_BIN))
+USE_RMDIR(NEWTOY(rmdir, "<1(ignore-fail-on-non-empty)p", TOYFLAG_BIN))
config RMDIR
bool "rmdir"
@@ -15,8 +15,10 @@ config RMDIR
Remove one or more directories.
-p Remove path
+ --ignore-fail-on-non-empty Ignore failures caused by non-empty directories
*/
+#define FOR_rmdir
#include "toys.h"
static void do_rmdir(char *name)
@@ -25,7 +27,8 @@ static void do_rmdir(char *name)
for (;;) {
if (rmdir(name)) {
- perror_msg_raw(name);
+ if (!FLAG(ignore_fail_on_non_empty) || errno != ENOTEMPTY)
+ perror_msg_raw(name);
return;
}