From b882f1e237a68c3d1074cbf63bda0207afb989b9 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 20 Jan 2007 23:41:49 -0500 Subject: Add "yes" command. --- toys/Config.in | 8 ++++++++ toys/toylist.h | 1 + toys/yes.c | 21 +++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 toys/yes.c (limited to 'toys') diff --git a/toys/Config.in b/toys/Config.in index 438785cd..64fa2a28 100644 --- a/toys/Config.in +++ b/toys/Config.in @@ -300,5 +300,13 @@ config WHICH -a Show all matches +config YES + bool "yes" + default n + help + usage: yes [args...] + + Repeatedly output line until killed. If no args, output 'y'. + endmenu diff --git a/toys/toylist.h b/toys/toylist.h index 4e45924e..270f4341 100644 --- a/toys/toylist.h +++ b/toys/toylist.h @@ -81,3 +81,4 @@ USE_PWD(NEWTOY(pwd, NULL, TOYFLAG_BIN)) USE_TOYSH(OLDTOY(sh, toysh, "c:i", TOYFLAG_BIN)) USE_TOYSH(NEWTOY(toysh, "c:i", TOYFLAG_BIN)) USE_WHICH(NEWTOY(which, "a", TOYFLAG_USR|TOYFLAG_BIN)) +USE_YES(NEWTOY(yes, "", TOYFLAG_USR|TOYFLAG_BIN)) diff --git a/toys/yes.c b/toys/yes.c new file mode 100644 index 00000000..860c331c --- /dev/null +++ b/toys/yes.c @@ -0,0 +1,21 @@ +/* vi: set sw=4 ts=4: */ +/* + * hello.c - A hello world program. + */ + +#include "toys.h" + +int yes_main(void) +{ + for (;;) { + int i; + for (i=0; toys.optargs[i]; i++) { + if (i) xputc(' '); + xprintf("%s", toys.optargs[i]); + } + if (!i) xputc('y'); + xputc('\n'); + } + + return 0; +} -- cgit v1.2.3