From eb2710c8883361cca7b69e424dcc9a3d31c94c05 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Wed, 2 Aug 2017 20:08:49 +0300 Subject: [PATCH] use cmd.exe as default shell on windows Mentioned in #12. --- app.go | 6 +++++- opts.go | 11 +++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app.go b/app.go index 091b3ecf..16da2351 100644 --- a/app.go +++ b/app.go @@ -140,7 +140,11 @@ func (app *app) runShell(s string, args []string, wait bool, async bool) { s = fmt.Sprintf("IFS='%s'; %s", gOpts.ifs, s) } - args = append([]string{"-c", s, "--"}, args...) + if runtime.GOOS == "windows" { + args = append([]string{"/c", s}, args...) + } else { + args = append([]string{"-c", s, "--"}, args...) + } cmd := exec.Command(gOpts.shell, args...) diff --git a/opts.go b/opts.go index a3ceef57..a6b79a8b 100644 --- a/opts.go +++ b/opts.go @@ -1,6 +1,9 @@ package main -import "time" +import ( + "runtime" + "time" +) var gOpts struct { dircounts bool @@ -40,7 +43,11 @@ func init() { gOpts.scrolloff = 0 gOpts.tabstop = 8 gOpts.filesep = ":" - gOpts.shell = "/bin/sh" + if runtime.GOOS == "windows" { + gOpts.shell = "cmd" + } else { + gOpts.shell = "/bin/sh" + } gOpts.sortby = "natural" gOpts.timefmt = time.ANSIC gOpts.ratios = []int{1, 2, 3}