aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toys/posix/rm.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/toys/posix/rm.c b/toys/posix/rm.c
index 7954daec..d9ad60d4 100644
--- a/toys/posix/rm.c
+++ b/toys/posix/rm.c
@@ -47,10 +47,9 @@ static int do_rm(struct dirtree *try)
// handle directory recursion
if (dir) {
-
if (try->data != -1) return DIRTREE_COMEAGAIN;
using = AT_REMOVEDIR;
- if (try->symlink) goto nodelete;
+ if (try->symlink) goto skip;
if (flags & FLAG_i) {
char *s = dirtree_path(try, 0);
// This is the section 2(d) prompt. (Yes, posix says to prompt twice.)
@@ -63,9 +62,9 @@ static int do_rm(struct dirtree *try)
skip:
if (unlinkat(fd, try->name, using)) {
- perror_msg("%s", try->name);
+ if (!dir || try->symlink != 2) perror_msg("%s", try->name);
nodelete:
- if (try->parent) try->parent->symlink = (char *)1;
+ if (try->parent) try->parent->symlink = (char *)2;
}
return 0;