Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 527

jq doesn't return non-zero for empty input

$
0
0

I have this line of code that works as expected:

echo '{"slot":"we"}' | jq -re '.slot' || exit 1

however this code doesn't raise an error even though I would expect so:

echo '' | jq -re '.slot' || exit 1

and neither does this:

echo '' | jq -re '.slot' || exit 1

how can I make sure that it raises an error if slot key is not found? What I mean is that in both last two examples the exit code is 0

enter image description here


Viewing all articles
Browse latest Browse all 527

Trending Articles