From 6631cdb23ba007b59b253b47b1670b5b5fbc3bd3 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Wed, 2 Aug 2017 19:52:48 +0300 Subject: [PATCH] use cmd.exe pause command for waiting on windows Mentioned in #12. --- app.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app.go b/app.go index 0dd2e84..091b3ec 100644 --- a/app.go +++ b/app.go @@ -5,6 +5,7 @@ import ( "log" "os" "os/exec" + "runtime" "strconv" "strings" ) @@ -45,7 +46,12 @@ func waitKey() error { stty $old echo` - cmd := exec.Command(gOpts.shell, "-c", c) + var cmd *exec.Cmd + if runtime.GOOS == "windows" { + cmd = exec.Command("cmd", "/c", "pause") + } else { + cmd = exec.Command(gOpts.shell, "-c", c) + } cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout @@ -135,6 +141,7 @@ func (app *app) runShell(s string, args []string, wait bool, async bool) { } args = append([]string{"-c", s, "--"}, args...) + cmd := exec.Command(gOpts.shell, args...) if !async {