Mercurial > hg > toybox
changeset 74:dfe99495acbc
Add "yes" command.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 20 Jan 2007 23:41:49 -0500 |
parents | fb56ba93afa3 |
children | 89ca591a9236 |
files | toys/Config.in toys/toylist.h toys/yes.c |
diffstat | 3 files changed, 30 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/toys/Config.in Sat Jan 20 22:59:00 2007 -0500 +++ b/toys/Config.in Sat Jan 20 23:41:49 2007 -0500 @@ -300,5 +300,13 @@ -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
--- a/toys/toylist.h Sat Jan 20 22:59:00 2007 -0500 +++ b/toys/toylist.h Sat Jan 20 23:41:49 2007 -0500 @@ -81,3 +81,4 @@ 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))
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toys/yes.c Sat Jan 20 23:41:49 2007 -0500 @@ -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; +}