Fixed option parsing. Grep would continue grepping, even when given a bad /
[oweals/busybox.git] / echo.c
diff --git a/echo.c b/echo.c
index a6b5152d8bfbf496d84492beba695e72b17ba3e1..31c0315289790aad1840a324e048d494302186be 100644 (file)
--- a/echo.c
+++ b/echo.c
  * Original copyright notice is retained at the end of this file.
  */
 
-#include "busybox.h"
 #include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "busybox.h"
 
 extern int 
 echo_main(int argc, char** argv)
@@ -38,7 +40,7 @@ echo_main(int argc, char** argv)
        while (argc > 0 && *argv[0] == '-')
        {
                register char *temp;
-               register int index;
+               register int ix;
 
                /*
                 * If it appears that we are handling options, then make sure
@@ -47,9 +49,9 @@ echo_main(int argc, char** argv)
                 */
                temp = argv[0] + 1;
 
-               for (index = 0; temp[index]; index++)
+               for (ix = 0; temp[ix]; ix++)
                {
-                       if (strrchr("neE", temp[index]) == 0)
+                       if (strrchr("neE", temp[ix]) == 0)
                                goto just_echo;
                }
 
@@ -79,7 +81,7 @@ echo_main(int argc, char** argv)
 
 just_echo:
        while (argc > 0) {
-               char *arg = argv[0];
+               const char *arg = argv[0];
                register int c;
 
                while ((c = *arg++)) {
@@ -107,7 +109,7 @@ just_echo:
                putchar('\n');
        fflush(stdout);
 
-       return 0;
+       return EXIT_SUCCESS;
 }
 
 /*-