Finish up yes(1) by adding multiple string support
This commit is contained in:
parent
27b770c02c
commit
f40608ef09
2
README
2
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
|
||||
|
|
8
yes.1
8
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.
|
||||
|
|
10
yes.c
10
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 */
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user