jq
jq copied to clipboard
Elif and optional else not working
Describe the bug
if has an optional else clause but it seems to not work in combination with one or more elif clauses.
To Reproduce
$ jq --version
jq-1.6-159-gcff5336
$ jq -n '1,2,3 | if . == 1 then 1 elif . == 2 then 2 end'
jq: error: syntax error, unexpected end (Unix shell quoting issues?) at <top-level>, line 1:
1,2,3 | if . == 1 then 1 elif . == 2 then 2 end
jq: error: Possibly unterminated 'if' statement at <top-level>, line 1:
1,2,3 | if . == 1 then 1 elif . == 2 then 2 end
jq: 2 compile errors
Expected behavior
$ jq -n '1,2,3 | if . == 1 then 1 elif . == 2 then 2 end'
1
2
3
Same as 1,2,3 | if . == 1 then 1 elif . == 2 then 2 else . end
Environment:
jq-1.6-159-gcff5336
Additional context
gojq supports optional else in combination with elif:s.