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 <nico@cryptonector.com>
This commit is contained in:
Assaf Gordon authored and Nicolas Williams committed 2015-03-24 14:55:14 -05:00
1 parent 4f8567476d
commit 551d875be1
1 file changed
+1 -1
+1 -1
View File
@@ -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)