3
0

yes.c 830 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 "libbb.h"
  15. /* This is a NOFORK applet. Be very careful! */
  16. int yes_main(int argc, char **argv);
  17. int yes_main(int argc, char **argv)
  18. {
  19. char **first_arg;
  20. argv[0] = (char*)"y";
  21. if (argc != 1) {
  22. ++argv;
  23. }
  24. first_arg = argv;
  25. do {
  26. while (1) {
  27. fputs(*argv, stdout);
  28. if (!*++argv)
  29. break;
  30. putchar(' ');
  31. }
  32. argv = first_arg;
  33. } while (putchar('\n') != EOF);
  34. bb_perror_nomsg_and_die();
  35. }