summaryrefslogtreecommitdiffstats
path: root/toolbox/rm.c
diff options
context:
space:
mode:
authorKen Sumrall <ksumrall@android.com>2013-06-28 02:47:00 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-06-28 02:47:01 +0000
commitcf0b4d94fae2009daaed135124971625dfece77b (patch)
treec7ca97a3e977187c24cfeb4ab23d882aae989673 /toolbox/rm.c
parent3b2b2b51376b1cf9da21155dacd8d9df106bf92d (diff)
parent035482976368dea4ddbda62230a6ec69025a65c3 (diff)
downloadsystem_core-cf0b4d94fae2009daaed135124971625dfece77b.zip
system_core-cf0b4d94fae2009daaed135124971625dfece77b.tar.gz
system_core-cf0b4d94fae2009daaed135124971625dfece77b.tar.bz2
Merge "Do not exit early on errors when -f is specified"
Diffstat (limited to 'toolbox/rm.c')
-rw-r--r--toolbox/rm.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/toolbox/rm.c b/toolbox/rm.c
index 127cbc4..957b586 100644
--- a/toolbox/rm.c
+++ b/toolbox/rm.c
@@ -45,8 +45,10 @@ static int unlink_recursive(const char* name, int flags)
continue;
sprintf(dn, "%s/%s", name, de->d_name);
if (unlink_recursive(dn, flags) < 0) {
- fail = 1;
- break;
+ if (!(flags & OPT_FORCE)) {
+ fail = 1;
+ break;
+ }
}
errno = 0;
}
@@ -71,6 +73,7 @@ int rm_main(int argc, char *argv[])
int ret;
int i, c;
int flags = 0;
+ int something_failed = 0;
if (argc < 2)
return usage();
@@ -110,10 +113,14 @@ int rm_main(int argc, char *argv[])
if (ret < 0) {
fprintf(stderr, "rm failed for %s, %s\n", argv[i], strerror(errno));
- return -1;
+ if (!(flags & OPT_FORCE)) {
+ return -1;
+ } else {
+ something_failed = 1;
+ }
}
}
- return 0;
+ return something_failed;
}