diff --git a/pkg/util/command_util.go b/pkg/util/command_util.go index 4330d60604..615ef99fa4 100644 --- a/pkg/util/command_util.go +++ b/pkg/util/command_util.go @@ -79,9 +79,10 @@ func ResolveEnvironmentReplacement(value string, envs []string, isFilepath bool) if err != nil { return "", err } + isDir := strings.HasSuffix(fp, pathSeparator) fp = filepath.Clean(fp) - if IsDestDir(value) && !IsDestDir(fp) { - fp = fp + "/" + if isDir && !strings.HasSuffix(fp, pathSeparator) { + fp = fp + pathSeparator } return fp, nil } diff --git a/pkg/util/command_util_test.go b/pkg/util/command_util_test.go index 616ad61e30..632ef2eb42 100644 --- a/pkg/util/command_util_test.go +++ b/pkg/util/command_util_test.go @@ -53,6 +53,14 @@ var testEnvReplacement = []struct { isFilepath: true, expectedPath: "/simple/path/", }, + { + path: "$simple", + envs: []string{ + "simple=/path/", + }, + isFilepath: true, + expectedPath: "/path/", + }, { path: "${a}/b", envs: []string{