Skip to content

Commit 58535a1

Browse files
Adding windows support for JobStart()
1 parent dea3e2a commit 58535a1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

internal/shell/job.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"io"
66
"os/exec"
7+
"runtime"
78
)
89

910
var Jobs chan JobFunction
@@ -54,7 +55,11 @@ func (f *CallbackFile) Write(data []byte) (int, error) {
5455
// JobStart starts a shell command in the background with the given callbacks
5556
// It returns an *exec.Cmd as the job id
5657
func JobStart(cmd string, onStdout, onStderr, onExit func(string, []interface{}), userargs ...interface{}) *Job {
57-
return JobSpawn("sh", []string{"-c", cmd}, onStdout, onStderr, onExit, userargs...)
58+
if runtime.GOOS == "windows" {
59+
return JobSpawn("cmd", []string{"/v:on", "/c", cmd}, onStdout, onStderr, onExit, userargs...)
60+
} else {
61+
return JobSpawn("sh", []string{"-c", cmd}, onStdout, onStderr, onExit, userargs...)
62+
}
5863
}
5964

6065
// JobSpawn starts a process with args in the background with the given callbacks

0 commit comments

Comments
 (0)