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

Patterns are not always parsed as such in conditions #221

Closed
ObserverOfTime opened this issue Oct 13, 2023 · 0 comments · Fixed by #245
Closed

Patterns are not always parsed as such in conditions #221

ObserverOfTime opened this issue Oct 13, 2023 · 0 comments · Fixed by #245

Comments

@ObserverOfTime
Copy link
Member

Conditional statement patterns should be (regex) nodes unless quoted.

Example with case

case $a in
  [a-zA-Z0-9]) ;;
esac

Current tree

(program [0, 0] - [3, 0]
  (case_statement [0, 0] - [2, 4]
    value: (simple_expansion [0, 5] - [0, 7]
      (variable_name [0, 6] - [0, 7]))
    (case_item [1, 2] - [1, 17]
      value: (concatenation [1, 2] - [1, 13]
        (word [1, 2] - [1, 3])
        (word [1, 3] - [1, 12])
        (word [1, 12] - [1, 13])))))

Expected tree

(program [0, 0] - [3, 0]
  (case_statement [0, 0] - [2, 4]
    value: (simple_expansion [0, 5] - [0, 7]
      (variable_name [0, 6] - [0, 7]))
    (case_item [1, 2] - [1, 17]
      value: (regex [1, 2] - [1, 13]))))

Example with [[

[[ $b = foo* ]]

Current tree

(program [0, 0] - [1, 0]
  (test_command [0, 0] - [0, 15]
    (binary_expression [0, 3] - [0, 12]
      left: (simple_expansion [0, 3] - [0, 5]
        (variable_name [0, 4] - [0, 5]))
      right: (word [0, 8] - [0, 12]))))

Expected tree

(program [0, 0] - [1, 0]
  (test_command [0, 0] - [0, 15]
    (binary_expression [0, 3] - [0, 12]
      left: (simple_expansion [0, 3] - [0, 5]
        (variable_name [0, 4] - [0, 5]))
      right: (regex [0, 8] - [0, 12]))))
@amaanq amaanq mentioned this issue Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant