Fixed "rm foo" that had been broken while implementing "rm -- foo"
diff --git a/coreutils/rm.c b/coreutils/rm.c
index 5901c5d..b1cda3a 100644
--- a/coreutils/rm.c
+++ b/coreutils/rm.c
@@ -68,14 +68,12 @@
int stopIt=FALSE;
struct stat statbuf;
- if (argc < 2) {
- usage(rm_usage);
- }
+ argc--;
argv++;
/* Parse any options */
- while (--argc >= 0 && *argv && **argv && stopIt==FALSE) {
- while (**argv == '-') {
+ while (argc > 0 && stopIt == FALSE) {
+ if (**argv == '-') {
while (*++(*argv))
switch (**argv) {
case 'R':
@@ -91,8 +89,15 @@
default:
usage(rm_usage);
}
+ argc--;
+ argv++;
}
- argv++;
+ else
+ break;
+ }
+
+ if (argc < 1 && forceFlag == FALSE) {
+ usage(rm_usage);
}
while (argc-- > 0) {