|
@@ -6,12 +6,17 @@ import (
|
|
)
|
|
)
|
|
|
|
|
|
var (
|
|
var (
|
|
- TOKEN_ENV_INTERPOLATION = regexp.MustCompile(`(\\\\+|[^\\]|\b|\A)\$({?)([[:alnum:]_]+)(}?)`)
|
|
|
|
|
|
+ // `\\\\+|[^\\]|\b|\A` - match any number of "\\" (ie, properly-escaped backslashes), or a single non-backslash character, or a word boundary, or beginning-of-line
|
|
|
|
+ // `\$` - match literal $
|
|
|
|
+ // `[[:alnum:]_]+` - match things like `$SOME_VAR`
|
|
|
|
+ // `{[[:alnum:]_]+}` - match things like `${SOME_VAR}`
|
|
|
|
+ tokenEnvInterpolation = regexp.MustCompile(`(\\\\+|[^\\]|\b|\A)\$([[:alnum:]_]+|{[[:alnum:]_]+})`)
|
|
|
|
+ // this intentionally punts on more exotic interpolations like ${SOME_VAR%suffix} and lets the shell handle those directly
|
|
)
|
|
)
|
|
|
|
|
|
// handle environment replacement. Used in dispatcher.
|
|
// handle environment replacement. Used in dispatcher.
|
|
func (b *Builder) replaceEnv(str string) string {
|
|
func (b *Builder) replaceEnv(str string) string {
|
|
- for _, match := range TOKEN_ENV_INTERPOLATION.FindAllString(str, -1) {
|
|
|
|
|
|
+ for _, match := range tokenEnvInterpolation.FindAllString(str, -1) {
|
|
match = match[strings.Index(match, "$"):]
|
|
match = match[strings.Index(match, "$"):]
|
|
matchKey := strings.Trim(match, "${}")
|
|
matchKey := strings.Trim(match, "${}")
|
|
|
|
|