-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
$ cat test.json
{"key": 1}
{"key": 2}
{"key": 3}
$ for i in 1 2 3 4
do
echo "==== i=$i ===="
jq --exit-status -c "select(.key == $i)" test.json
echo ret=$?
done
==== i=1 ====
{"key":1}
ret=4
==== i=2 ====
{"key":2}
ret=4
==== i=3 ====
{"key":3}
ret=0
==== i=4 ====
ret=4
The man page says "Sets the exit status of jq to [...] 4 if no valid result was ever produced", but it seems the command returns 4 whenever last object is filtered out. (it should return '4' only for i=4 case above)
$ jq --exit-status -c 'select(.key == 1) | (.key!=1) ' test.json; echo ret=$?
false
ret=4
Similarly, I think this should return '1' instead of 4, because it's last output (which is not last one in the input, though) is 'false'.
Metadata
Metadata
Assignees
Labels
No labels