blob: ead674b27eacffa722e01d638ceaac08fdfcc479 [file] [log] [blame]
Erik Andersene49d5ec2000-02-08 19:58:47 +00001/* vi: set sw=4 ts=4: */
Erik Andersen31638212000-01-15 22:28:50 +00002/*
Manuel Novoa III cad53642003-03-19 09:13:01 +00003 * yes implementation for busybox
Erik Andersen31638212000-01-15 22:28:50 +00004 *
Manuel Novoa III cad53642003-03-19 09:13:01 +00005 * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
Erik Andersen31638212000-01-15 22:28:50 +00006 *
"Robert P. J. Day"801ab142006-07-12 07:56:04 +00007 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
Erik Andersen31638212000-01-15 22:28:50 +00008 */
9
Manuel Novoa III cad53642003-03-19 09:13:01 +000010/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
11
12/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
13 *
14 * Size reductions and removed redundant applet name prefix from error messages.
15 */
Eric Andersen8d4c3972001-03-09 21:28:09 +000016
Denis Vlasenkob6adbf12007-05-26 19:00:18 +000017#include "libbb.h"
Erik Andersen31638212000-01-15 22:28:50 +000018
Denis Vlasenko99912ca2007-04-10 15:43:37 +000019/* This is a NOFORK applet. Be very careful! */
20
Denys Vlasenkof2177ab2010-06-06 05:23:09 +020021//usage:#define yes_trivial_usage
22//usage: "[STRING]"
23//usage:#define yes_full_usage "\n\n"
24//usage: "Repeatedly output a line with STRING, or 'y'"
25
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000026int yes_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denys Vlasenkoe992bae2009-11-28 15:18:53 +010027int yes_main(int argc UNUSED_PARAM, char **argv)
Erik Andersene49d5ec2000-02-08 19:58:47 +000028{
Denis Vlasenko62a90cd2008-03-17 09:07:36 +000029 char **pp;
Erik Andersene49d5ec2000-02-08 19:58:47 +000030
Denis Vlasenko99912ca2007-04-10 15:43:37 +000031 argv[0] = (char*)"y";
Denys Vlasenkoe992bae2009-11-28 15:18:53 +010032 if (argv[1])
Manuel Novoa III cad53642003-03-19 09:13:01 +000033 ++argv;
Erik Andersen31638212000-01-15 22:28:50 +000034
Manuel Novoa III cad53642003-03-19 09:13:01 +000035 do {
Denis Vlasenko62a90cd2008-03-17 09:07:36 +000036 pp = argv;
Denis Vlasenko99912ca2007-04-10 15:43:37 +000037 while (1) {
Denis Vlasenko62a90cd2008-03-17 09:07:36 +000038 fputs(*pp, stdout);
39 if (!*++pp)
Denis Vlasenko99912ca2007-04-10 15:43:37 +000040 break;
41 putchar(' ');
42 }
Manuel Novoa III cad53642003-03-19 09:13:01 +000043 } while (putchar('\n') != EOF);
Matt Kraai90f580a2000-09-22 03:45:34 +000044
Manuel Novoa III cad53642003-03-19 09:13:01 +000045 bb_perror_nomsg_and_die();
Erik Andersen31638212000-01-15 22:28:50 +000046}