Restore CmdLine parameter when running commands using cmd.exe

This commit is contained in:
Junegunn Choi 2024-04-28 15:55:30 +09:00
parent f39ae0e7c1
commit 159a37fa37
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
1 changed files with 14 additions and 4 deletions

View File

@ -57,10 +57,20 @@ func (x *Executor) ExecCommand(command string, setpgid bool) *exec.Cmd {
}
x.shellPath.Store(shell)
}
cmd := exec.Command(shell, append(x.args, command)...)
cmd.SysProcAttr = &syscall.SysProcAttr{
HideWindow: false,
CreationFlags: 0,
var cmd *exec.Cmd
if strings.Contains(shell, "cmd") {
cmd = exec.Command(shell)
cmd.SysProcAttr = &syscall.SysProcAttr{
HideWindow: false,
CmdLine: fmt.Sprintf(`%s "%s"`, strings.Join(x.args, " "), command),
CreationFlags: 0,
}
} else {
cmd = exec.Command(shell, append(x.args, command)...)
cmd.SysProcAttr = &syscall.SysProcAttr{
HideWindow: false,
CreationFlags: 0,
}
}
return cmd
}