feat: option to change POSIX variable name regex - facilitate passthrough #573
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.
Background
There are certain situations where a string
${xxxxxxxx}
should not be a candidate for variable substitution. This is very common in Spring Boot applications where${a.b.c.d}
is property placeholder syntaxThis PR allows the user to narrow the scope of
dotenv.variables._posix_variable
so that some strings that resemble POSIX variable substitution can be treated literally.Before this PR:
After this PR:
Real-world use case: 12-factor'ing Spring Boot applications where some properties refer to other properties
${a.b.c.d}
in their valuesFeature Implementation
dotenv.set_variable_name_pattern(....)
to set the regex for the naming convention. This is a substring that will be used inside the${xxxxxx:-yyyyyy}
matcher. IOW, this pattern is only used to match the variable name, not the enclosing${...}
dotenv.set_variable_name_pattern()
This feature does not affect any existing code as it is purely opt-in
Thread Safety
dotenv.variables
so is not thread safeDeferred Ideas
_posix_variable
- this would be very intrusive so not in the scope of this feature_posix_variable
- this is a low risk thread-safety enhancement where each thread can set its own_posix_variable
Usage
Benefits
Workaround
Current workaround