1
0
mirror of https://github.com/stedolan/jq.git synced 2024-05-11 05:55:39 +00:00

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
2015-03-09 23:43:31 -04:00
committed by Nicolas Williams
parent 4f8567476d
commit 551d875be1

2
main.c
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)