bash-parser
bash-parser copied to clipboard
Parse variable substitution
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