summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLieuwe Rooijakkers <lieuwerooijakkers@gmail.com>2024-08-04 15:12:51 +0200
committerLieuwe Rooijakkers <lieuwerooijakkers@gmail.com>2024-08-04 15:12:51 +0200
commit091cc88ee3ee9483bc1858bb4ff59da674fe69e6 (patch)
treebb438c17b43e6a7abd3cbdbb815d7cb7370d51a2
parentd8b7e45a5900f677fb6ef19a5eb51855071520aa (diff)
don't quit early when encountering mapje
-rw-r--r--src/hoofd.c2
-rw-r--r--src/kat.c2
-rw-r--r--src/tak.c2
-rw-r--r--src/toilet.c2
-rw-r--r--src/util/loop_args.c7
5 files changed, 9 insertions, 6 deletions
diff --git a/src/hoofd.c b/src/hoofd.c
index 0eac51d..c02d166 100644
--- a/src/hoofd.c
+++ b/src/hoofd.c
@@ -101,7 +101,7 @@ err_file:
err_isdir:
fprintf(stderr, "hoofd: bestand '%s' is een mapje\n", arg);
- return 1;
+ return -1;
}
int entry_hoofd(int argc, char **argv) {
diff --git a/src/kat.c b/src/kat.c
index 923307a..acaf54c 100644
--- a/src/kat.c
+++ b/src/kat.c
@@ -74,7 +74,7 @@ err_file:
err_isdir:
fprintf(stderr, "kat: bestand '%s' is een mapje\n", arg);
- return 1;
+ return -1;
}
int entry_kat(int argc, char **argv) {
diff --git a/src/tak.c b/src/tak.c
index ca01fab..0cda9d5 100644
--- a/src/tak.c
+++ b/src/tak.c
@@ -92,7 +92,7 @@ err_file:
err_isdir:
fprintf(stderr, "tak: bestand '%s' is een mapje\n", arg);
- return 1;
+ return -1;
}
int entry_tak(int argc, char **argv) {
diff --git a/src/toilet.c b/src/toilet.c
index d9c2556..8ee0bfa 100644
--- a/src/toilet.c
+++ b/src/toilet.c
@@ -154,7 +154,7 @@ err_file:
err_isdir:
fprintf(stderr, "toilet: bestand '%s' is een mapje\n", arg);
- return 1;
+ return -1;
}
int entry_toilet(int argc, char **argv) {
diff --git a/src/util/loop_args.c b/src/util/loop_args.c
index 4609c71..0ab6a7a 100644
--- a/src/util/loop_args.c
+++ b/src/util/loop_args.c
@@ -7,6 +7,8 @@ int loop_args(char **args, int (*callback)(char *argv, bool isstdin)) {
return callback(*args, true);
}
+ int stickyErr = 0;
+
while (*args != NULL) {
int res = 0;
if (!strcmp(*args, "-")) {
@@ -15,10 +17,11 @@ int loop_args(char **args, int (*callback)(char *argv, bool isstdin)) {
res = callback(*args, false);
}
- if (res != 0) return res;
+ if (res > 0) return res;
+ else if (res < 0 && stickyErr == 0) stickyErr = -res;
args++;
}
- return 0;
+ return stickyErr;
}