wide/vendor/github.com/visualfc/gotools/terminal/command.go

34 lines
403 B
Go
Raw Normal View History

2018-03-13 08:11:10 +03:00
// +build !windows
package terminal
import (
"io"
"os"
"os/exec"
"github.com/kr/pty"
)
func GetShell() (cmd string, args []string) {
return "/bin/sh", []string{"-l", "-i"}
}
func Execute(c *exec.Cmd) error {
f, err := pty.Start(c)
if err != nil {
return nil
}
go func() {
for {
io.Copy(f, os.Stdin)
}
}()
go func() {
for {
io.Copy(os.Stdout, f)
}
}()
return c.Wait()
}