Created
March 7, 2019 18:38
-
-
Save velicanu/f4f2bd8a5e67a3f0c4ad7bff89f8dab7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo Normal behavior, returns a: | |
echo '{}' | jq '(try (["a"]) catch null) as $selected | if $selected|length<2 then $selected[0] else "halt error" | halt_error end' | |
echo | |
echo Normal behavior, returns a: | |
echo '{}' | jq '(try (["a"]) catch null) as $selected | if $selected|length<2 then $selected[0] else "normal error" | error end' | |
echo | |
echo Normal behavior, returns halt error: | |
echo '{}' | jq '(try (["a","b"]) catch null) as $selected | if $selected|length<2 then $selected[0] else "halt error\n" | halt_error end' | |
echo | |
echo Unexpected behavior, returns null instead of "normal error": | |
echo '{}' | jq '(try (["a","b"]) catch null) as $selected | if $selected|length<2 then $selected[0] else ("normal error" | error) end' | |
echo | |
echo Normal behavior, returns foo: | |
echo '{}' | jq '(try (["a","b"]) catch null) as $selected | if $selected|length<2 then $selected[0] else "foo" end' | |
echo | |
echo Normal behavior, returns a: | |
echo '{}' | jq '(try (["a","b"]) catch null) as $selected | if true then $selected[0] else "normal error" | error end' | |
echo | |
echo Normal behavior, returns normal error: | |
echo '{}' | jq '(try (["a","b"]) catch null) as $selected | if false then $selected[0] else "normal error" | error end' | |
echo | |
echo Normal behavior, returns halt error: | |
echo '{}' | jq '["a","b"] as $selected | if $selected|length<2 then $selected[0] else "halt error\n" | halt_error end' | |
echo | |
echo Normal behavior, returns normal error: | |
echo '{}' | jq '["a","b"] as $selected | if $selected|length<2 then $selected[0] else "normal error" | error end' | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment