Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elif and optional else not working #2481

Closed
wader opened this issue Sep 6, 2022 · 0 comments · Fixed by #2598
Closed

Elif and optional else not working #2481

wader opened this issue Sep 6, 2022 · 0 comments · Fixed by #2598

Comments

@wader
Copy link
Member

wader commented Sep 6, 2022

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.

wader added a commit to wader/jq that referenced this issue Jun 1, 2023
wader added a commit to wader/jq that referenced this issue Jun 1, 2023
@itchyny itchyny added dependencies Pull requests that update a dependency file feature request and removed dependencies Pull requests that update a dependency file labels Jun 3, 2023
@itchyny itchyny added this to the 1.7 release milestone Jun 25, 2023
wader added a commit to wader/jq that referenced this issue Jul 1, 2023
wader added a commit to wader/jq that referenced this issue Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants