diff options
author | Ken Sumrall <ksumrall@android.com> | 2013-06-25 22:29:06 -0700 |
---|---|---|
committer | Ken Sumrall <ksumrall@android.com> | 2013-06-26 17:42:38 -0700 |
commit | 035482976368dea4ddbda62230a6ec69025a65c3 (patch) | |
tree | d699f28bfe08336044229e946f94accbbdf8e737 /toolbox/rm.c | |
parent | 13495a1cbb6c6b7ec617488f272bc02f2107a63c (diff) | |
download | core-035482976368dea4ddbda62230a6ec69025a65c3.tar.gz core-035482976368dea4ddbda62230a6ec69025a65c3.tar.bz2 core-035482976368dea4ddbda62230a6ec69025a65c3.zip |
Do not exit early on errors when -f is specified
When running with the -f option, do not stop recursion or proccessing
command line args if an error occurs. Continue trying to remove all
the items specified on the command line. However, still return an
error status if some files could not be removed.
Change-Id: I83d66babe833da8a68aad68248647ba0601c5d32
Diffstat (limited to 'toolbox/rm.c')
-rw-r--r-- | toolbox/rm.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/toolbox/rm.c b/toolbox/rm.c index 127cbc450..957b5867f 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; } |