find: Don't exit successfully after errors - sbase - suckless unix tools
 (HTM) git clone git://git.suckless.org/sbase
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 556797632991c4458682aa4cc7399a69ac7c77a8
 (DIR) parent 8f9824e34bbf5a7c61a425ebfca93bff6364ecb9
 (HTM) Author: Tavian Barnes <tavianator@tavianator.com>
       Date:   Sat, 22 Feb 2025 13:14:49 +0100
       
       find: Don't exit successfully after errors
       
       Diffstat:
         M find.c                              |       4 ++++
       
       1 file changed, 4 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/find.c b/find.c
       @@ -964,6 +964,7 @@ find(char *path, struct findhist *hist)
        
                if (do_stat(path, &st, hist) < 0) {
                        weprintf("failed to stat %s:", path);
       +                gflags.ret = 1;
                        return;
                }
        
       @@ -985,6 +986,7 @@ find(char *path, struct findhist *hist)
                for (f = hist; f; f = f->next) {
                        if (f->dev == st.st_dev && f->ino == st.st_ino) {
                                weprintf("loop detected '%s' is '%s'\n", path, f->path);
       +                        gflags.ret = 1;
                                return;
                        }
                }
       @@ -995,6 +997,7 @@ find(char *path, struct findhist *hist)
        
                if (!(dir = opendir(path))) {
                        weprintf("failed to opendir %s:", path);
       +                gflags.ret = 1;
                        /* should we just ignore this since we hit an error? */
                        if (gflags.depth)
                                eval(root, &arg);
       @@ -1018,6 +1021,7 @@ find(char *path, struct findhist *hist)
                free(pathbuf);
                if (errno) {
                        weprintf("readdir %s:", path);
       +                gflags.ret = 1;
                        closedir(dir);
                        return;
                }