3
0

yes.c 795 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * yes implementation for busybox
  4. *
  5. * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
  6. *
  7. * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  8. */
  9. /* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
  10. /* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
  11. *
  12. * Size reductions and removed redundant applet name prefix from error messages.
  13. */
  14. #include "busybox.h"
  15. int yes_main(int argc, char **argv)
  16. {
  17. static const char fmt_str[] = " %s";
  18. const char *fmt;
  19. char **first_arg;
  20. *argv = "y";
  21. if (argc != 1) {
  22. ++argv;
  23. }
  24. first_arg = argv;
  25. do {
  26. fmt = fmt_str + 1;
  27. do {
  28. printf(fmt, *argv);
  29. fmt = fmt_str;
  30. } while (*++argv);
  31. argv = first_arg;
  32. } while (putchar('\n') != EOF);
  33. bb_perror_nomsg_and_die();
  34. }