blob: 894506a89d53f60e99f9f188cd0bac5b7eab92fe [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
Eric Andersencbe31da2001-02-20 06:14:08 +000017#include "busybox.h"
Erik Andersen31638212000-01-15 22:28:50 +000018
Rob Landleydfba7412006-03-06 20:47:33 +000019int yes_main(int argc, char **argv)
Erik Andersene49d5ec2000-02-08 19:58:47 +000020{
Manuel Novoa III cad53642003-03-19 09:13:01 +000021 static const char fmt_str[] = " %s";
22 const char *fmt;
23 char **first_arg;
Erik Andersene49d5ec2000-02-08 19:58:47 +000024
Manuel Novoa III cad53642003-03-19 09:13:01 +000025 *argv = "y";
26 if (argc != 1) {
27 ++argv;
Erik Andersene5b6c7d2000-04-17 16:16:10 +000028 }
Erik Andersen31638212000-01-15 22:28:50 +000029
Manuel Novoa III cad53642003-03-19 09:13:01 +000030 first_arg = argv;
31 do {
32 fmt = fmt_str + 1;
33 do {
Denis Vlasenkof0ed3762006-10-26 23:21:47 +000034 printf(fmt, *argv);
Manuel Novoa III cad53642003-03-19 09:13:01 +000035 fmt = fmt_str;
36 } while (*++argv);
37 argv = first_arg;
38 } while (putchar('\n') != EOF);
Matt Kraai90f580a2000-09-22 03:45:34 +000039
Manuel Novoa III cad53642003-03-19 09:13:01 +000040 bb_perror_nomsg_and_die();
Erik Andersen31638212000-01-15 22:28:50 +000041}