Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Change how escaped expansions work back to only "expanding" to a
$
- but still capture the potential identifier or brace expression that follows.Given
BAR=bar
,$${FOO:$BAR}
expands to${FOO:bar}
and$${FOO:$$BAR}
expands to${FOO:$BAR}
(the pre-#10) behaviour).While I'm here, do a bunch of work on the tests.
Why
Fixes #14
How
Originally,
\$
and$$
were parsed into a single$
as plain text, and it didn't affect the interpretation of the following text.We had the need to find potential "run-time" interpolations in buildkite-agent, so "escaped expansions" were added that parse like "normal" variable expansions, but produce different text when expanded.
EscapedExpansion
then had to be expanded (ahem) to handle brace expressions as well.Here are the key changes in this PR:
and here.
Previously,
EscapedExpansion
would capture the identifier or brace expression that followed it. This caused problems for the interpretation of nested expansions: if the escaped dollarsign were treated simply as text as it should be, then expressions nested within the brace following the escaped dollarsign could be parsed and expanded as intended. Instead, because the brace was captured byEscapedExpansion
, and expanded verbatim, that wouldn't happen.Now,
EscapedExpansion
goes back to expanding only to$
. Instead of capturing the following identifier or brace for expansion, it records what it was, then the parser restarts from the same position as text.