Environment replacement
This commit is contained in:
parent
cf24231121
commit
f56b3e9542
|
|
@ -38,9 +38,24 @@ func ResolveEnvironmentReplacement(command, value string, envs []string) (string
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
shlex := shell.NewLex(p.EscapeToken)
|
shlex := shell.NewLex(p.EscapeToken)
|
||||||
processedWord, err := shlex.ProcessWord(value, envs)
|
return shlex.ProcessWord(value, envs)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResolveFilepathEnvironmentReplacement replaces env variables in filepaths
|
||||||
|
// and returns a cleaned version of the path
|
||||||
|
func ResolveFilepathEnvironmentReplacement(command, value string, envs []string) (string, error) {
|
||||||
|
p, err := parser.Parse(bytes.NewReader([]byte(command)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return filepath.Clean(processedWord), nil
|
shlex := shell.NewLex(p.EscapeToken)
|
||||||
|
fp, err := shlex.ProcessWord(value, envs)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
fp = filepath.Clean(fp)
|
||||||
|
if filepath.IsAbs(value) {
|
||||||
|
fp = filepath.Join(fp, "/")
|
||||||
|
}
|
||||||
|
return fp, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue