Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include escaped interpolations in identifiers #10

Merged
merged 4 commits into from
May 30, 2024

Conversation

moskyb
Copy link
Contributor

@moskyb moskyb commented May 30, 2024

a reopening of #9 against main, #9 was helpfully auto-closed by github when its base branch, master, was deleted. sigh.

original description follows

It's useful for consumers of this libary to be able to know if their input contains things that would be interpolated, and if so, which things. Currently, this is handled by the interpolate.Identifiers() function, which returns a list of the interpolate-able identifiers that interpolate.Interpolate() would replace.

However, this library makes one further modification to its input: when escaped expansions are included (ie, $$MY_VAR or \$MY_VAR), they're de-escaped in the output. This is working as intended, but the interpolate.Identifiers function doesn't include these escaped interpolations, which is a bit confusing when you're using the Identifiers function to determine "will running Interpolate() change the input?"

To remedy this, this PR updates the parse to handle escaped interpolations a bit differently, and treat them as a kind of expansion that doesn't take any input, and de-escapes its input. There's no functionality change, but escaped interpolations now show up in the Identifiers() function

This PR also does a little bit of housekeeping - adding a buildkite pipeline, specifying the go version in the go.mod file, etc. Once it's merged, i'll make a release so that we can version this using go modules.

wow, embarrassing that that was missing, huh?
It's useful for consumers of this libary to be able to know if their input contains things that would be interpolated, and if so, which things. Currently, this is handled by the `interpolate.Identifiers()` function, which returns a list of the interpolate-able identifiers that `interpolate.Interpolate()` would replace.

However, this library makes one further modification to its input: when escaped expansions are included (ie, $$MY_VAR or \$MY_VAR), they're de-escaped in the output. This is working as intended, but the `interpolate.Identifiers` function doesn't include these escaped interpolations, which is a bit confusing when you're using the `Identifiers` function to determine "will running Interpolate() change the input?"

To remedy this, this PR updates the parse to handle escaped interpolations a bit differently, and treat them as a kind of expansion that doesn't take any input, and de-escapes its input. There's no functionality change, but escaped interpolations now show up in the `Identifiers()` function
@moskyb moskyb enabled auto-merge May 30, 2024 06:44
Copy link
Contributor

@DrJosh9000 DrJosh9000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🫑

@moskyb moskyb merged commit ced93a2 into main May 30, 2024
1 check passed
@moskyb moskyb deleted the include-escaped-interpolations-in-identifiers-2 branch May 30, 2024 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants