OSDN Git Service

Add "yes" command.
authorRob Landley <rob@landley.net>
Sun, 21 Jan 2007 04:41:49 +0000 (23:41 -0500)
committerRob Landley <rob@landley.net>
Sun, 21 Jan 2007 04:41:49 +0000 (23:41 -0500)
toys/Config.in
toys/toylist.h
toys/yes.c [new file with mode: 0644]

index 438785c..64fa2a2 100644 (file)
@@ -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
 
index 4e45924..270f434 100644 (file)
@@ -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 (file)
index 0000000..860c331
--- /dev/null
@@ -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;
+}