Skip to content

Parse variable substitution #64

@jcubic

Description

@jcubic

It seems that variable substitutions are not parsed, they are single expressions. I think that they should be split up if this to be a full bash parser.

replace:

${i/jcubic/JCUBIC}

as AST is:

{
  type: 'Script',
  commands: [
    {
      type: 'Command',
      name: {
        text: '${i/jcubic/JCUBIC}',
        expansion: [
          {
            loc: { start: 0, end: 17 },
            parameter: 'i/jcubic/JCUBIC',
            type: 'ParameterExpansion'
          }
        ],
        type: 'Word'
      }
    }
  ]
}

if anyone wants to use this parser she needs to parse the parameter herself.

Substitution is documented here https://tldp.org/LDP/abs/html/parameter-substitution.html

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