summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/loop_args.c7
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;
}