Nir Lichtman pointed out that rm -p shouldn't try to rmdir / at the end.

This commit is contained in:
Rob Landley 2021-03-20 00:09:51 -05:00
parent 3aaf63f6d9
commit 855eca3eaf
2 changed files with 6 additions and 2 deletions

View File

@ -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" \

View File

@ -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)