URI: 
       tAdd flag to watch directories recursively - wendy - watch files/directories and run commands on any event
  HTML git clone git://z3bra.org/wendy
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 6c09b1154ee762731099b081edbb39ae686df4a0
   DIR parent f1ecd626eacbcac98fe252a4b7b5a463acaed2d6
  HTML Author: Willy Goiffon <dev@z3bra.org>
       Date:   Fri, 28 Feb 2020 20:01:17 +0100
       
       Add flag to watch directories recursively
       
       Diffstat:
         M wendy.c                             |      18 ++++++++++++++++--
       
       1 file changed, 16 insertions(+), 2 deletions(-)
       ---
   DIR diff --git a/wendy.c b/wendy.c
       t@@ -41,7 +41,7 @@ int verbose = 1;
        void
        usage(char *name)
        {
       -        fprintf(stderr, "usage: %s [-v] [-m mask] [-f file] [cmd [args..]]\n", name);
       +        fprintf(stderr, "usage: %s [-vr] [-m mask] [-f file]\n", name);
                exit(1);
        }
        
       t@@ -102,10 +102,11 @@ wdpath(struct inotify_event *e)
        int
        main (int argc, char **argv)
        {
       -        int fd;
       +        int fd, rflag = 0;
                uint8_t buf[EVSZ];
                uint32_t mask = IN_ALL_EVENTS;
                ssize_t len, off = 0;
       +        char path[PATH_MAX];
                char *argv0 = NULL;
                struct watcher *tmp, *w;
                struct inotify_event *e;
       t@@ -116,6 +117,9 @@ main (int argc, char **argv)
                        perror("inotify_init");
        
                ARGBEGIN {
       +        case 'r':
       +                rflag = 1;
       +                break;
                case 'm':
                        mask = atoi(EARGF(usage(argv0)));
                        break;
       t@@ -145,6 +149,16 @@ main (int argc, char **argv)
                                fflush(stdout);
                        }
        
       +                switch(e->mask & IN_ALL_EVENTS) {
       +                case IN_CREATE:
       +                        /* Watch subdirectories upon creation */
       +                        if (rflag && e->mask & IN_ISDIR) {
       +                                snprintf(path, PATH_MAX, "%s/%s", w->path, e->name);
       +                                watch(fd, path, mask);
       +                        }
       +                        break;
       +                }
       +
                        /*
                         * IN_IGNORED is triggered when a file watched
                         * doesn't exists anymore. In this case we first try to