aboutsummaryrefslogtreecommitdiff
path: root/coreutils/echo.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-07-14 18:39:08 +0000
committerEric Andersen <andersen@codepoet.org>2000-07-14 18:39:08 +0000
commitadd09fd558c8a336554fbf8b381ab0f8e180382a (patch)
tree2ccbcd48f335161c647be3f2c296cae06aceb671 /coreutils/echo.c
parent17ad45aace3141d1b997208a43979495ead98f7c (diff)
downloadbusybox-add09fd558c8a336554fbf8b381ab0f8e180382a.tar.gz
Getopt'ed by Marc Nijdam <marc_nijdam@hp.com>
-Erik
Diffstat (limited to 'coreutils/echo.c')
-rw-r--r--coreutils/echo.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/coreutils/echo.c b/coreutils/echo.c
index 6e279d1c6..387ea3fef 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) {