From 9dac741f831a13757fd0dfa0a71992a65b8af289 Mon Sep 17 00:00:00 2001 From: AGitBoy Date: Sun, 30 Jun 2019 22:17:14 -0400 Subject: [PATCH] Simplified yes codebase --- yes.1 | 4 ++-- yes.c | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/yes.1 b/yes.1 index 87e390a..519343d 100644 --- a/yes.1 +++ b/yes.1 @@ -6,9 +6,9 @@ .Nd output strings repeatedly .Sh SYNOPSIS .Nm -.Op Ar string ... +.Op Ar string .Sh DESCRIPTION .Nm -will repeatedly write 'y' or a line with each +will repeatedly write 'y' or .Ar string to stdout. diff --git a/yes.c b/yes.c index ffc77f0..d4da256 100644 --- a/yes.c +++ b/yes.c @@ -6,23 +6,21 @@ static void usage(void) { - eprintf("usage: %s [string ...]\n", argv0); + eprintf("usage: %s [string]\n", argv0); } int main(int argc, char *argv[]) { - char **p; - ARGBEGIN { default: usage(); } ARGEND - for (p = argv; ; p = (*p && *(p + 1)) ? p + 1 : argv) { - fputs(*p ? *p : "y", stdout); - putchar((!*p || !*(p + 1)) ? '\n' : ' '); - } + char *p = argc > 1 ? argv[1] : "y"; + + for (;;) + puts(p); return 1; /* not reached */ } -- 2.21.0