Explorar o código

bugfix: Empty environment variable names causing exec failures on Windows, thanks @sirjmann92 ! (#353)

James Read %!s(int64=2) %!d(string=hai) anos
pai
achega
9dd33bc3f9
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  1. 8 1
      internal/executor/executor.go

+ 8 - 1
internal/executor/executor.go

@@ -380,7 +380,14 @@ func buildEnv(req *ExecutionRequest) []string {
 	ret := append(os.Environ(), "OLIVETIN=1")
 
 	for k, v := range req.Arguments {
-		ret = append(ret, fmt.Sprintf("%v=%v", strings.ToUpper(k), v))
+		varName := fmt.Sprintf("%v", strings.TrimSpace(strings.ToUpper(k)))
+
+		// Skip arguments that might not have a name (eg, confirmation), as this causes weird bugs on Windows.
+		if varName == "" {
+			continue
+		}
+
+		ret = append(ret, fmt.Sprintf("%v=%v", varName, v))
 	}
 
 	return ret