aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtests/rmdir.test4
-rw-r--r--toys/posix/rmdir.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/tests/rmdir.test b/tests/rmdir.test
index 5b36bbc1..1731ecc2 100755
--- a/tests/rmdir.test
+++ b/tests/rmdir.test
@@ -40,6 +40,10 @@ testing "-p part of path" \
"yes\n" "" ""
rm -rf temp
+skipnot [ $UID -eq 0 ]
+testing '-p abspath' \
+ 'mkdir -p /test/2/3 && rmdir -p /test/2/3 && [ ! -e /test ] && echo yes' \
+ 'yes\n' '' ''
mkdir -p one/two/three
testing "-p one/two/three" \
diff --git a/toys/posix/rmdir.c b/toys/posix/rmdir.c
index c25fd839..3714f334 100644
--- a/toys/posix/rmdir.c
+++ b/toys/posix/rmdir.c
@@ -25,7 +25,7 @@ static void do_rmdir(char *name)
{
char *temp;
- for (;;) {
+ do {
if (rmdir(name)) {
if (!FLAG(ignore_fail_on_non_empty) || errno != ENOTEMPTY)
perror_msg_raw(name);
@@ -39,7 +39,7 @@ static void do_rmdir(char *name)
if (!(temp = strrchr(name, '/'))) return;
*temp = 0;
} while (!temp[1]);
- }
+ } while (*name);
}
void rmdir_main(void)