Use arg.h in nopen(1) - noice - small file browser (mirror / fork from 2f30.org)
 (HTM) git clone git://git.codemadness.org/noice
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 2b8e1ac48a355d0185665bd9f4b1c30d2747b1dd
 (DIR) parent 53c35e6b340b7c135038e00057a198f03cb7d7cf
 (HTM) Author: sin <sin@2f30.org>
       Date:   Fri, 23 Aug 2019 15:52:13 +0100
       
       Use arg.h in nopen(1)
       
       Diffstat:
         M Makefile                            |       2 +-
         M nopen.c                             |      17 ++++++++++++-----
       
       2 files changed, 13 insertions(+), 6 deletions(-)
       ---
 (DIR) diff --git a/Makefile b/Makefile
       @@ -19,7 +19,7 @@ nopen: $(NOPENOBJ)
        
        dprintf.o: util.h
        noice.o: arg.h noiceconf.h util.h
       -nopen.o: nopenconf.h util.h
       +nopen.o: arg.h nopenconf.h util.h
        spawn.o: util.h
        strlcat.o: util.h
        strlcpy.o: util.h
 (DIR) diff --git a/nopen.c b/nopen.c
       @@ -8,6 +8,7 @@
        #include <string.h>
        #include <unistd.h>
        
       +#include "arg.h"
        #include "util.h"
        
        struct assoc {
       @@ -19,6 +20,8 @@ struct assoc {
        
        #include "nopenconf.h"
        
       +char *argv0;
       +
        void
        run(struct assoc *assoc, char *arg)
        {
       @@ -67,7 +70,7 @@ initassocs(void)
        }
        
        void
       -usage(char *argv0)
       +usage(void)
        {
                fprintf(stderr, "usage: %s file...\n", argv0);
                exit(1);
       @@ -76,10 +79,14 @@ usage(char *argv0)
        int
        main(int argc, char *argv[])
        {
       -        if (argc == 1)
       -                usage(argv[0]);
       -        argc--;
       -        argv++;
       +        ARGBEGIN {
       +        default:
       +                usage();
       +        } ARGEND
       +
       +        if (argc == 0)
       +                usage();
       +
                initassocs();
                for (; *argv != NULL; argv++) {
                        struct assoc *assoc;