Improve windows shell handling

This commit is contained in:
Joe Lim committed 2023-06-18 00:24:06 +10:00
1 parent e885abe1a3
commit 3b398d4aec
1 file changed
+9 -4
+9 -4
View File
@@ -101,11 +101,16 @@ func detachedCommand(name string, arg ...string) *exec.Cmd {
}
func shellCommand(s string, args []string) *exec.Cmd {
args = append([]string{gOpts.shellflag, s}, args...)
var builder strings.Builder
builder.WriteString(s)
for _, arg := range args {
fmt.Fprintf(&builder, ` "%s"`, arg)
}
cmdline := fmt.Sprintf(`%s %s "%s"`, gOpts.shellopts, gOpts.shellflag, builder.String())
args = append(gOpts.shellopts, args...)
return exec.Command(gOpts.shell, args...)
cmd := exec.Command(gOpts.shell)
cmd.SysProcAttr = &windows.SysProcAttr{CmdLine: cmdline}
return cmd
}
func shellSetPG(cmd *exec.Cmd) {