diff options
author | Lieuwe Rooijakkers <lieuwerooijakkers@gmail.com> | 2024-08-04 15:12:51 +0200 |
---|---|---|
committer | Lieuwe Rooijakkers <lieuwerooijakkers@gmail.com> | 2024-08-04 15:12:51 +0200 |
commit | 091cc88ee3ee9483bc1858bb4ff59da674fe69e6 (patch) | |
tree | bb438c17b43e6a7abd3cbdbb815d7cb7370d51a2 /src | |
parent | d8b7e45a5900f677fb6ef19a5eb51855071520aa (diff) |
don't quit early when encountering mapje
Diffstat (limited to 'src')
-rw-r--r-- | src/hoofd.c | 2 | ||||
-rw-r--r-- | src/kat.c | 2 | ||||
-rw-r--r-- | src/tak.c | 2 | ||||
-rw-r--r-- | src/toilet.c | 2 | ||||
-rw-r--r-- | src/util/loop_args.c | 7 |
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) { @@ -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) { @@ -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; } |