From 551d875be112c60345fc0c5d4dc85b059b39b66c Mon Sep 17 00:00:00 2001 From: Assaf Gordon Date: Mon, 9 Mar 2015 23:43:31 -0400 Subject: [PATCH] always propagate input errors to exit code Improve robustness in automated system when using exit code in shell scripts, by exiting with code 2 if there was any input error (even overriding other possible error exit codes). Exit code 2 is already used to indicate system errors. Without the patch: $ jq . no-such-file ; echo $? jq: no-such-file: No such file or directory 0 With the patch: $ jq . no-such-file ; echo $? jq: no-such-file: No such file or directory 2 Signed-off-by: Nicolas Williams --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 8999598f..b76b0724 100644 --- a/main.c +++ b/main.c @@ -474,7 +474,7 @@ int main(int argc, char* argv[]) { } } - if (jq_util_input_open_errors(input_state) != 0 && ret == 0 && (options & EXIT_STATUS)) + if (jq_util_input_open_errors(input_state) != 0) ret = 2; if (ret != 0)