support env vars at the end of the command #11

This commit is contained in:
piotr
2021-08-15 14:34:25 +02:00
parent 033a4d59ae
commit d732e9e070

View File

@@ -583,17 +583,19 @@ func launch(command string, terminal bool) {
envVarsNum := strings.Count(command, "=")
var envVars []string
cmdIdx := 0
lastEnvVarIdx := 0
cmdIdx := -1
if envVarsNum > 0 {
for idx, item := range elements {
if strings.Contains(item, "=") {
lastEnvVarIdx = idx
envVars = append(envVars, item)
} else if !strings.HasPrefix(item, "-") && cmdIdx == -1 {
cmdIdx = idx
}
}
cmdIdx = lastEnvVarIdx + 1
}
if cmdIdx == -1 {
cmdIdx = 0
}
cmd := exec.Command(elements[cmdIdx], elements[1+cmdIdx:]...)