diff options
author | Eric Andersen | 2000-08-22 01:00:56 +0000 |
---|---|---|
committer | Eric Andersen | 2000-08-22 01:00:56 +0000 |
commit | ce82c8ab7782d30ae639652f10d9d9f4069410aa (patch) | |
tree | 54853663d564d33633115d3466ea440f04a77d7c /chmod_chown_chgrp.c | |
parent | 2368a387edced9e9722d6b8e7a82bd2e191ca347 (diff) | |
download | busybox-ce82c8ab7782d30ae639652f10d9d9f4069410aa.zip busybox-ce82c8ab7782d30ae639652f10d9d9f4069410aa.tar.gz |
Fix an option parsing bug where things like
chmod -r /tmp/file
wholdn't work (since it thought -r was an option). Doh!
-Erik
Diffstat (limited to 'chmod_chown_chgrp.c')
-rw-r--r-- | chmod_chown_chgrp.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/chmod_chown_chgrp.c b/chmod_chown_chgrp.c index c02f2a3..b347707 100644 --- a/chmod_chown_chgrp.c +++ b/chmod_chown_chgrp.c @@ -76,6 +76,7 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk) int chmod_chown_chgrp_main(int argc, char **argv) { + int stopIt = FALSE; int recursiveFlag = FALSE; char *groupName=NULL; char *p=NULL; @@ -94,26 +95,28 @@ int chmod_chown_chgrp_main(int argc, char **argv) /* Parse options */ while (--argc >= 0 && *argv && (**argv == '-')) { - while (*++(*argv)) { + while (stopIt==FALSE && *++(*argv)) { switch (**argv) { case 'R': recursiveFlag = TRUE; break; default: - errorMsg(invalid_option, **argv); - usage(appUsage); + theMode=*argv-1; + stopIt = TRUE; } } + if (stopIt==TRUE) + break; argv++; } if (argc == 0 || *argv == NULL) { errorMsg(too_few_args); - usage(appUsage); } if (whichApp == CHMOD_APP) { - theMode = *argv; + if (theMode==NULL) + theMode = *argv; } else { /* Find the selected group */ @@ -152,7 +155,7 @@ int chmod_chown_chgrp_main(int argc, char **argv) } /* Ok, ready to do the deed now */ - if (argc <= 1) { + if (argc < 1) { fatalError(too_few_args); } while (argc-- > 1) { |