yes.c 517 B

1234567891011121314151617181920212223242526272829
  1. /* yes.c - Repeatedly output a string.
  2. *
  3. * Copyright 2007 Rob Landley <rob@landley.net>
  4. USE_YES(NEWTOY(yes, NULL, TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_LINEBUF))
  5. config YES
  6. bool "yes"
  7. default y
  8. help
  9. usage: yes [args...]
  10. Repeatedly output line until killed. If no args, output 'y'.
  11. */
  12. #include "toys.h"
  13. void yes_main(void)
  14. {
  15. for (;;) {
  16. int i;
  17. for (i=0; toys.optargs[i]; i++) {
  18. if (i) xputc(' ');
  19. xprintf("%s", toys.optargs[i]);
  20. }
  21. if (!i) xputc('y');
  22. xputc('\n');
  23. }
  24. }