Skip to content

Bash 5.3 command substitution syntax parses as ERROR #301

@Iron-E

Description

@Iron-E

(If this isn't the right place to report this, please let me know!)

Revision: 56b54c6

Reference: https://www.gnu.org/software/bash/manual/bash.html#Command-Substitution-1

tree-sitter version: 0.25.6 (used via Neovim v0.11.3)

Minimal examples:

Click to expand
#!/usr/bin/env bash

echo "${ echo foo; }"

It currently parses as:

(program ; [0, 0] - [3, 0]
  (comment) ; [0, 0] - [0, 19]
  (command ; [2, 0] - [2, 21]
    name: (command_name ; [2, 0] - [2, 4]
      (word)) ; [2, 0] - [2, 4]
    argument: (string ; [2, 5] - [2, 21]
      (expansion ; [2, 6] - [2, 20]
        (variable_name) ; [2, 9] - [2, 13]
        (ERROR ; [2, 13] - [2, 18]
          (word)))))) ; [2, 14] - [2, 17]
Click to expand
#!/usr/bin/env bash

echo "${| REPLY=12345; }"

It currently parses as:

(program ; [0, 0] - [3, 0]
  (comment) ; [0, 0] - [0, 19]
  (command ; [2, 0] - [2, 25]
    name: (command_name ; [2, 0] - [2, 4]
      (word)) ; [2, 0] - [2, 4]
    argument: (string ; [2, 5] - [2, 25]
      (ERROR ; [2, 6] - [2, 24]
        (word))))) ; [2, 8] - [2, 23]
Click to expand
#!/usr/bin/env bash

echo "${
  echo "${
    echo foo
  }"
}"

It currently parses as:

(program ; [0, 0] - [7, 0]
  (comment) ; [0, 0] - [0, 19]
  (command ; [2, 0] - [6, 2]
    name: (command_name ; [2, 0] - [2, 4]
      (word)) ; [2, 0] - [2, 4]
    argument: (concatenation ; [2, 5] - [6, 2]
      (string ; [2, 5] - [3, 8]
        (ERROR ; [2, 6] - [3, 6]
          (variable_name))) ; [3, 2] - [3, 6]
      (expansion ; [3, 8] - [5, 3]
        (variable_name) ; [4, 4] - [4, 8]
        (ERROR ; [4, 9] - [4, 12]
          (word))) ; [4, 9] - [4, 12]
      (string ; [5, 3] - [6, 2]
        (string_content))))) ; [6, 0] - [6, 1]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions