Under the description for the -f option, POSIX says, "Do not modify the exit status in the case of nonexistent operands". --- libutil/rm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/libutil/rm.c b/libutil/rm.c index 53ae3f2..30a1b41 100644 --- a/libutil/rm.c +++ b/libutil/rm.c @@ -1,5 +1,7 @@ /* See LICENSE file for copyright and license details. */ +#include <errno.h> #include <stdio.h> +#include <sys/stat.h> #include "../fs.h" #include "../util.h" @@ -11,11 +13,14 @@ int rm_status = 0; void rm(const char *path, int unused) { + struct stat st; + if (rm_rflag) recurse(path, rm, 'P'); if (remove(path) < 0) { if (!rm_fflag) weprintf("remove %s:", path); - rm_status = 1; + if (!rm_fflag || stat(path, &st) < 0 && errno != ENOENT) + rm_status = 1; } } -- 2.1.3.1.g339ec9c