diff --git a/README b/README index cbf4929..e752242 100644 --- a/README +++ b/README @@ -84,7 +84,7 @@ The following tools are implemented ('*' == finished, '#' == UTF-8 support, = sha512sum non-posix none wc yes none = xargs no -I, -L, -p, -s, -t, -x -= yes yes none +=* yes yes none The complement of sbase is ubase[1] which is Linux-specific and provides all the non-portable tools. Together they are intended to diff --git a/yes.1 b/yes.1 index f47e888..73240e1 100644 --- a/yes.1 +++ b/yes.1 @@ -1,12 +1,14 @@ -.Dd January 30, 2015 +.Dd January 31, 2015 .Dt YES 1 .Os sbase .Sh NAME .Nm yes -.Nd output a string repeatedly +.Nd output strings repeatedly .Sh SYNOPSIS .Nm .Op Ar string ... .Sh DESCRIPTION .Nm -will repeatedly output 'y' or the strings specified. +will repeatedly write 'y' or a line with each +.Ar string +to stdout. diff --git a/yes.c b/yes.c index 3652536..fe9af7f 100644 --- a/yes.c +++ b/yes.c @@ -7,18 +7,22 @@ static void usage(void) { - eprintf("usage: %s [string]\n", argv0); + eprintf("usage: %s [string ...]\n", argv0); } int main(int argc, char *argv[]) { + size_t i; + ARGBEGIN { default: usage(); } ARGEND; - for (;;) - puts(argc >= 1 ? argv[0] : "y"); + for (i = 0; ;i++, i %= argc) { + printf("%s", (argc > 0) ? argv[i] : "y"); + putchar((i == argc - 1) ? '\n' : ' '); + } return 1; /* should not reach */ }