jqの--exit-statusオプションについて調べてまとめたので100ブクマぐらいお願いします
manすると1文が長くてつらい。neither A nor Bとか懐かしい。両方否定ね。
man jq
o -e / --exit-status: Sets the exit status of jq to 0 if the last output values was nei- ther false nor null, 1 if the last output value was either false or null, or 4 if no valid result was ever produced. Normally jq exits with 2 if there was any usage problem or system error, 3 if there was a jq program compile error, or 0 if the jq program ran.
まとめ
command | stdout | exit status |
---|---|---|
$ echo '{}' | jq . |
{} |
0 |
$ echo '{}' | jq --exit-status . |
{} |
0 |
$ echo 'true' | jq . |
true |
0 |
$ echo 'true' | jq --exit-status . |
true |
0 |
$ echo 'false' | jq . |
false |
0 |
$ echo 'false' | jq --exit-status . |
false |
1 |
$ echo 'null' | jq . |
null |
0 |
$ echo 'null' | jq --exit-status . |
null |
1 |
$ echo 'foo' | jq . |
*1 | 4 |
$ echo 'foo' | jq --exit-status . |
*2 | 4 |
以上です