diff options
author | Eric Andersen | 2000-07-14 18:39:08 +0000 |
---|---|---|
committer | Eric Andersen | 2000-07-14 18:39:08 +0000 |
commit | add09fd558c8a336554fbf8b381ab0f8e180382a (patch) | |
tree | 2ccbcd48f335161c647be3f2c296cae06aceb671 /coreutils/echo.c | |
parent | 17ad45aace3141d1b997208a43979495ead98f7c (diff) | |
download | busybox-add09fd558c8a336554fbf8b381ab0f8e180382a.zip busybox-add09fd558c8a336554fbf8b381ab0f8e180382a.tar.gz |
Getopt'ed by Marc Nijdam <marc_nijdam@hp.com>
-Erik
Diffstat (limited to 'coreutils/echo.c')
-rw-r--r-- | coreutils/echo.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/coreutils/echo.c b/coreutils/echo.c index 6e279d1..387ea3f 100644 --- a/coreutils/echo.c +++ b/coreutils/echo.c @@ -45,23 +45,24 @@ echo_main(int argc, char** argv) int nflag = 0; int eflag = 0; - ap = argv; - if (argc) - ap++; - while ((p = *ap) != NULL && *p == '-') { - if (strcmp(p, "-n")==0) { + + while ((c = getopt(argc, argv, "neE")) != EOF) { + switch (c) { + case 'n': nflag = 1; - } else if (strcmp(p, "-e")==0) { + break; + case 'e': eflag = 1; - } else if (strcmp(p, "-E")==0) { + break; + case 'E': eflag = 0; + break; + default: + usage(uname_usage); } - else if (strncmp(p, "--", 2)==0) { - usage( uname_usage); - } - else break; - ap++; } + + ap = &argv[optind]; while ((p = *ap++) != NULL) { while ((c = *p++) != '\0') { if (c == '\\' && eflag) { |