Skip to content

Commit 19a5962

Browse files
committed
sync
1 parent 4de4efc commit 19a5962

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

stream/cmd/command.go

+7-9
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,14 @@ func (s *Session) SetDir(dir string) { s.dir = strings.TrimSpace(dir) }
3838
func (s *Session) SetLog(wr io.Writer) { s.logWriter = wr }
3939
func (s *Session) GetPid() <-chan int { return s.pid }
4040
func (s *Session) run(ctx context.Context, command string) string {
41-
var cmd *exec.Cmd
42-
switch runtime.GOOS {
43-
case "windows":
44-
cmd = exec.Command("cmd", "/C", command)
45-
case "linux", "darwin", "freebsd":
46-
cmd = exec.Command("bash", "-c", command)
47-
}
48-
if cmd == nil {
49-
return ""
41+
fnInitCmd := func() *exec.Cmd {
42+
if runtime.GOOS == "windows" {
43+
return exec.Command("cmd", "/C", command)
44+
}
45+
return exec.Command("bash", "-c", command) //"linux", "darwin", "freebsd":
5046
}
47+
cmd := fnInitCmd()
48+
5149
cmd.Dir = s.dir
5250
mylog.Warning("go-command", cmd.String())
5351
outputErr := &bytes.Buffer{}

0 commit comments

Comments
 (0)