[hackers] [sbase] Simplify yes(1) || sin

From: <git_AT_suckless.org>
Date: Sat, 05 Oct 2013 16:29:54 +0200

commit a8ef54bae11a3d63d2f4f1fbc488af6416644a5d
Author: sin <sin_AT_2f30.org>
Date: Sat Oct 5 15:04:50 2013 +0100

    Simplify yes(1)
    
    Just pick the first argument if multiple are provided.

diff --git a/yes.c b/yes.c
index a55a022..ebbbdf9 100644
--- a/yes.c
+++ b/yes.c
_AT_@ -8,24 +8,13 @@ static void usage(void);
 int
 main(int argc, char *argv[])
 {
- char *s = "y";
-
         ARGBEGIN {
         default:
                 usage();
         } ARGEND;
 
- switch(argc) {
- case 1:
- s = argv[0];
- /* fallthrough */
- case 0:
- for(;;)
- puts(s);
- break;
- default:
- usage();
- }
+ for (;;)
+ puts(argc >= 1 ? argv[0] : "y");
         return EXIT_FAILURE; /* should not reach */
 }
 
Received on Sat Oct 05 2013 - 16:29:54 CEST

This archive was generated by hypermail 2.3.0 : Sat Oct 05 2013 - 16:37:05 CEST