Simplify yes(1)

Just pick the first argument if multiple are provided.
This commit is contained in:
sin 2013-10-05 15:04:50 +01:00
parent 3a3cd24092
commit a8ef54bae1

15
yes.c
View File

@ -8,24 +8,13 @@ static void usage(void);
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
char *s = "y";
ARGBEGIN { ARGBEGIN {
default: default:
usage(); usage();
} ARGEND; } ARGEND;
switch(argc) { for (;;)
case 1: puts(argc >= 1 ? argv[0] : "y");
s = argv[0];
/* fallthrough */
case 0:
for(;;)
puts(s);
break;
default:
usage();
}
return EXIT_FAILURE; /* should not reach */ return EXIT_FAILURE; /* should not reach */
} }