commit cfe9424ba92c735613723ab18427d091f825de34
parent b27871013b1debede7a5177f915be3f7b75aaee3
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Fri, 2 May 2025 10:41:35 +0200
rm: Fix regression from b278710
The forbidden() function only checks if we are trying to remove one of
the . .. or / directories that are forbidden by POSIX, and it should
not fail when it cannot stat a target, because that check is done later
considering if -r, -f and -i were used or not. If the stat fails we can
be sure that is not / and thus it is not a forbidden target.
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rm.c b/rm.c
@@ -33,7 +33,7 @@ forbidden(char *path, struct stat *root)
}
if (stat(path, &st) < 0)
- eprintf("stat argument '%s':", path);
+ return 0;
if (st.st_dev == root->st_dev && st.st_ino == root->st_ino) {
if (!w2)
weprintf("\"/\" may not be removed\n");