summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-08-03 08:11:17 -0400
committerJakob Kaivo <jkk@ung.org>2019-08-03 08:11:17 -0400
commitd50106289b3b0f2e5d1fdaa42cef9ce36ff71515 (patch)
tree1579b45325bc630f2ad4806c885516cc46379f2f
parent17a6074c3ce52752afd8a367498610224fb4930d (diff)
chain conditionals to trip use of continue statements
-rw-r--r--rm.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/rm.c b/rm.c
index 1602224..21d8e0f 100644
--- a/rm.c
+++ b/rm.c
@@ -132,27 +132,26 @@ int main(int argc, char **argv)
char base[strlen(path) + 1];
strcpy(base, path);
char *b = basename(base);
+ struct stat st;
if (!strcmp(b, "/") || !strcmp(b, ".") || !strcmp(b, "..")) {
fprintf(stderr, "rm: %s: %s\n", path, strerror(EINVAL));
retval = 1;
- continue;
- }
- struct stat st;
- if (lstat(path, &st) != 0) {
- if (mode != FORCE) {
- fprintf(stderr, "rm: %s: %s\n", path, strerror(errno));
- retval = 1;
+ } else if (lstat(path, &st) != 0) {
+ if (mode == FORCE) {
+ continue;
}
- continue;
- }
+ fprintf(stderr, "rm: %s: %s\n", path, strerror(errno));
+ retval = 1;
- if (recursive) {
+ } else if (recursive) {
nftw(path, rm, OPEN_MAX, FTW_DEPTH | FTW_PHYS);
+
} else {
rm(path, &st, 0, NULL);
}
+
} while (++optind < argc);
return retval;