# HG changeset patch # User Rob Landley # Date 1169354509 18000 # Node ID dfe99495acbcc050d61a4651a355b60773e2a103 # Parent fb56ba93afa3aeb58f5bc34fb75e804110389f6d Add "yes" command. diff -r fb56ba93afa3 -r dfe99495acbc toys/Config.in --- 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 diff -r fb56ba93afa3 -r dfe99495acbc toys/toylist.h --- 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)) diff -r fb56ba93afa3 -r dfe99495acbc toys/yes.c --- /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; +}