blob: 81d875589cc98f011ae494c84593efa2d0573897 [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 *
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02007 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
Erik Andersen31638212000-01-15 22:28:50 +00008 */
Manuel Novoa III cad53642003-03-19 09:13:01 +00009/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
10 *
11 * Size reductions and removed redundant applet name prefix from error messages.
12 */
Denys Vlasenkoaf3f4202016-11-23 14:46:56 +010013//config:config YES
14//config: bool "yes"
15//config: default y
16//config: help
17//config: yes is used to repeatedly output a specific string, or
18//config: the default string `y'.
Eric Andersen8d4c3972001-03-09 21:28:09 +000019
Denys Vlasenkoaf3f4202016-11-23 14:46:56 +010020//applet:IF_YES(APPLET_NOFORK(yes, yes, BB_DIR_USR_BIN, BB_SUID_DROP, yes))
Erik Andersen31638212000-01-15 22:28:50 +000021
Denys Vlasenkoaf3f4202016-11-23 14:46:56 +010022//kbuild:lib-$(CONFIG_YES) += yes.o
23
24/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
Denis Vlasenko99912ca2007-04-10 15:43:37 +000025
Denys Vlasenkof2177ab2010-06-06 05:23:09 +020026//usage:#define yes_trivial_usage
27//usage: "[STRING]"
28//usage:#define yes_full_usage "\n\n"
29//usage: "Repeatedly output a line with STRING, or 'y'"
30
Denys Vlasenkoaf3f4202016-11-23 14:46:56 +010031#include "libbb.h"
32
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000033int yes_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denys Vlasenkoe992bae2009-11-28 15:18:53 +010034int yes_main(int argc UNUSED_PARAM, char **argv)
Erik Andersene49d5ec2000-02-08 19:58:47 +000035{
Denis Vlasenko62a90cd2008-03-17 09:07:36 +000036 char **pp;
Erik Andersene49d5ec2000-02-08 19:58:47 +000037
Denis Vlasenko99912ca2007-04-10 15:43:37 +000038 argv[0] = (char*)"y";
Denys Vlasenkoe992bae2009-11-28 15:18:53 +010039 if (argv[1])
Manuel Novoa III cad53642003-03-19 09:13:01 +000040 ++argv;
Erik Andersen31638212000-01-15 22:28:50 +000041
Manuel Novoa III cad53642003-03-19 09:13:01 +000042 do {
Denis Vlasenko62a90cd2008-03-17 09:07:36 +000043 pp = argv;
Denis Vlasenko99912ca2007-04-10 15:43:37 +000044 while (1) {
Denis Vlasenko62a90cd2008-03-17 09:07:36 +000045 fputs(*pp, stdout);
46 if (!*++pp)
Denis Vlasenko99912ca2007-04-10 15:43:37 +000047 break;
48 putchar(' ');
49 }
Manuel Novoa III cad53642003-03-19 09:13:01 +000050 } while (putchar('\n') != EOF);
Matt Kraai90f580a2000-09-22 03:45:34 +000051
Manuel Novoa III cad53642003-03-19 09:13:01 +000052 bb_perror_nomsg_and_die();
Erik Andersen31638212000-01-15 22:28:50 +000053}