fix: failed to exec command line on windows

This commit is contained in:
xucong053
2022-09-30 13:17:39 +08:00
parent a43b95add6
commit 7a553f31b6
3 changed files with 15 additions and 4 deletions

View File

@@ -69,6 +69,11 @@ func ensurePython3Venv(venv string, packages ...string) (python3 string, err err
return python3, nil
}
func Command(name string, arg ...string) *exec.Cmd {
args := strings.Join(arg, " ")
return exec.Command("bash", "-c", name, args)
}
func ExecCommand(cmdName string, args ...string) error {
cmd := exec.Command(cmdName, args...)
log.Info().Str("cmd", cmd.String()).Msg("exec command")

View File

@@ -100,6 +100,11 @@ func ensurePython3Venv(venvDir string, packages ...string) (python3 string, err
return python3, nil
}
func Command(name string, arg ...string) *exec.Cmd {
args := strings.Join(arg, " ")
return exec.Command("cmd", "/c", name, args)
}
func ExecCommand(cmdName string, args ...string) error {
// "cmd /c" carries out the command specified by string and then stops
// refer: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/cmd