ParameterExpansion does not allow empty substitution
Opened this issue · 1 comments
I seem to have found that the ParameterExpansion does not allow an empty substitution.
${parameter:-word}
If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is substituted.
Example:
# test if var is was set before or not
if [ -z "${var:-}" ]; then
var="var was not set before"
fi
Could you have look or tell me where i can change the grammar to allow an empty word, so i can make a pull request.
It seems we are not handling empty string in parameter-expansion.js:
bash-parser/src/modes/posix/rules/parameter-expansion.js
Lines 24 to 33 in e7bc5eb
Since the value to substitute has to be further expanded, we recursively pass it to bash-parser (at the time I can't think of a better way).
When substituting with an empty string, we try to parse an empty string, and that fail. You can try
to change the code there and skip the parsing in this particular case.