I am trying to parse my curl output with JQ and check the exit code, so when my curl output is empty, JQ return 0 exit code.
For example:
$ echo "" | jq '.key'
$ echo $?
0
How to make this return 1 or some non-zero value?
I am trying to parse my curl output with JQ and check the exit code, so when my curl output is empty, JQ return 0 exit code.
For example:
$ echo "" | jq '.key'
$ echo $?
0
How to make this return 1 or some non-zero value?
You should use
inputwith-n/--null-inputon the command line. This way JQ will fail if its input is empty.