From 44741f51a46f8e6c99ff015e0568e11d9526ac01 Mon Sep 17 00:00:00 2001 From: Ethan Sommer Date: Sun, 29 Sep 2019 12:07:32 -0400 Subject: Add rmdir --ignore-fail-on-non-empty --- toys/posix/rmdir.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'toys/posix') 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; } -- cgit v1.2.3