Fix handling of permission addition and removal (e.g., o-r).
[oweals/busybox.git] / coreutils / yes.c
index 1718af4bb8891d46b9a72e1e0c51d5ce8d9378eb..7d9596d0bf72156b53426ec0013254a6fdd127a1 100644 (file)
  *
  */
 
-#include "internal.h"
+/* getopt not needed */
+
 #include <stdio.h>
+#include <stdlib.h>
+#include "busybox.h"
 
 extern int yes_main(int argc, char **argv)
 {
        int i;
 
-       if (argc >= 2 && *argv[1] == '-') {
-               usage("yes [OPTION]... [STRING]...\n"
-#ifndef BB_FEATURE_TRIVIAL_HELP
-                               "\nRepeatedly outputs a line with all specified STRING(s), or `y'.\n"
-#endif
-                               );
-       }
+       if (argc >= 2 && *argv[1] == '-')
+               show_usage();
 
        if (argc == 1) {
                while (1)
                        if (puts("y") == EOF) {
                                perror("yes");
-                               exit(FALSE);
+                               return EXIT_FAILURE;
                        }
        }
 
@@ -48,7 +46,8 @@ extern int yes_main(int argc, char **argv)
                        if (fputs(argv[i], stdout) == EOF
                                || putchar(i == argc - 1 ? '\n' : ' ') == EOF) {
                                perror("yes");
-                               exit(FALSE);
+                               return EXIT_FAILURE;
                        }
-       exit(TRUE);
+
+       return EXIT_SUCCESS;
 }