bash-parser icon indicating copy to clipboard operation
bash-parser copied to clipboard

Parse variable substitution

Open jcubic opened this issue 4 years ago • 0 comments
trafficstars

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

jcubic avatar Jul 21 '21 13:07 jcubic