diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2000-06-06 16:15:23 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2000-06-06 16:15:23 +0000 |
commit | 088238cc727a9594cc20e6caed137fc532671188 (patch) | |
tree | 0955917be0c7adc926b7298bf450fedc67e447e6 /rm.c | |
parent | 0763f791683f2323a24e5ec82fc2deafc70b5dd1 (diff) | |
download | busybox-w32-088238cc727a9594cc20e6caed137fc532671188.tar.gz busybox-w32-088238cc727a9594cc20e6caed137fc532671188.tar.bz2 busybox-w32-088238cc727a9594cc20e6caed137fc532671188.zip |
Fixed a bunch of stuff:
* Fixed segfault caused by "touch -c"
* Fixed segfault caused by "rm -f"
* Fixed segfault caused by "ln -s -s" and similar abuses.
* Fixed segfault caused by "cp -a -a" and similar abuses.
* Implemented "rm -- <foo>"
updated docs accordingly.
-Erik
git-svn-id: svn://busybox.net/trunk/busybox@613 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'rm.c')
-rw-r--r-- | rm.c | 37 |
1 files changed, 21 insertions, 16 deletions
@@ -31,7 +31,8 @@ | |||
31 | 31 | ||
32 | static const char *rm_usage = "rm [OPTION]... FILE...\n" | 32 | static const char *rm_usage = "rm [OPTION]... FILE...\n" |
33 | #ifndef BB_FEATURE_TRIVIAL_HELP | 33 | #ifndef BB_FEATURE_TRIVIAL_HELP |
34 | "\nRemove (unlink) the FILE(s).\n\n" | 34 | "\nRemove (unlink) the FILE(s). You may use '--' to\n" |
35 | "indicate that all following arguments are non-options.\n\n" | ||
35 | "Options:\n" | 36 | "Options:\n" |
36 | "\t-f\t\tremove existing destinations, never prompt\n" | 37 | "\t-f\t\tremove existing destinations, never prompt\n" |
37 | "\t-r or -R\tremove the contents of directories recursively\n" | 38 | "\t-r or -R\tremove the contents of directories recursively\n" |
@@ -64,29 +65,33 @@ static int dirAction(const char *fileName, struct stat *statbuf, void* junk) | |||
64 | 65 | ||
65 | extern int rm_main(int argc, char **argv) | 66 | extern int rm_main(int argc, char **argv) |
66 | { | 67 | { |
68 | int stopIt=FALSE; | ||
67 | struct stat statbuf; | 69 | struct stat statbuf; |
68 | 70 | ||
69 | if (argc < 2) { | 71 | if (argc < 2) { |
70 | usage(rm_usage); | 72 | usage(rm_usage); |
71 | } | 73 | } |
72 | argc--; | ||
73 | argv++; | 74 | argv++; |
74 | 75 | ||
75 | /* Parse any options */ | 76 | /* Parse any options */ |
76 | while (**argv == '-') { | 77 | while (--argc >= 0 && *argv && **argv && stopIt==FALSE) { |
77 | while (*++(*argv)) | 78 | while (**argv == '-') { |
78 | switch (**argv) { | 79 | while (*++(*argv)) |
79 | case 'R': | 80 | switch (**argv) { |
80 | case 'r': | 81 | case 'R': |
81 | recursiveFlag = TRUE; | 82 | case 'r': |
82 | break; | 83 | recursiveFlag = TRUE; |
83 | case 'f': | 84 | break; |
84 | forceFlag = TRUE; | 85 | case 'f': |
85 | break; | 86 | forceFlag = TRUE; |
86 | default: | 87 | break; |
87 | usage(rm_usage); | 88 | case '-': |
88 | } | 89 | stopIt = TRUE; |
89 | argc--; | 90 | break; |
91 | default: | ||
92 | usage(rm_usage); | ||
93 | } | ||
94 | } | ||
90 | argv++; | 95 | argv++; |
91 | } | 96 | } |
92 | 97 | ||