Simplify yes(1)
Just pick the first argument if multiple are provided.
This commit is contained in:
parent
3a3cd24092
commit
a8ef54bae1
15
yes.c
15
yes.c
@ -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 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user