[hackers] [sbase][PATCH 2/6] find: Don't exit successfully after errors

From: Tavian Barnes <tavianator_AT_tavianator.com>
Date: Fri, 14 Feb 2025 11:25:05 -0500

---
 find.c | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/find.c b/find.c
index 7243072..ce551e5 100644
--- a/find.c
+++ b/find.c
_AT_@ -960,6 +960,7 @@ find(char *path, struct findhist *hist)
 
 	if (do_stat(path, &st, hist) < 0) {
 		weprintf("failed to stat %s:", path);
+		gflags.ret = 1;
 		return;
 	}
 
_AT_@ -981,6 +982,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;
 		}
 	}
_AT_@ -991,6 +993,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);
_AT_@ -1014,6 +1017,7 @@ find(char *path, struct findhist *hist)
 	free(pathbuf);
 	if (errno) {
 		weprintf("readdir %s:", path);
+		gflags.ret = 1;
 		closedir(dir);
 		return;
 	}
-- 
2.48.1
Received on Fri Feb 14 2025 - 17:25:05 CET

This archive was generated by hypermail 2.3.0 : Fri Feb 14 2025 - 21:24:37 CET