Skip to content

Commit 3cd57a6

Browse files
author
Alberto Fanjul
committed
set bool env var correctly on windows
1 parent 36c69f1 commit 3cd57a6

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

test/extended/crc/cmd/cmd.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,23 @@ func (c Command) env() []string {
9797
return env
9898
}
9999

100-
func envVariable(key, value string) string {
100+
func EnvVariable(key, value string) string {
101+
var prefix = ""
102+
var suffix = ""
101103
if runtime.GOOS == "windows" {
102-
return fmt.Sprintf("$env:%s=%s;", key, value)
104+
prefix = "$env:"
105+
suffix = ";"
106+
switch value {
107+
case "true":
108+
value = "$true"
109+
break
110+
case "false":
111+
value = "$false"
112+
break
113+
default:
114+
}
103115
}
104-
return fmt.Sprintf("%s=%s", key, value)
116+
return fmt.Sprintf("%s%s=%s%s", prefix, key, value, suffix)
105117
}
106118

107119
func (c Command) validate() error {

0 commit comments

Comments
 (0)