Finish up yes(1) by adding multiple string support

This commit is contained in:
FRIGN
2015-02-01 02:13:47 +01:00
parent 27b770c02c
commit f40608ef09
3 changed files with 13 additions and 7 deletions

10
yes.c
View File

@@ -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 */
}