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/util | |
parent | d8b7e45a5900f677fb6ef19a5eb51855071520aa (diff) |
don't quit early when encountering mapje
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/loop_args.c | 7 |
1 files changed, 5 insertions, 2 deletions
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; } |