diff --git a/cmd/print.go b/cmd/print.go index a23048071..c7b7a7b03 100644 --- a/cmd/print.go +++ b/cmd/print.go @@ -81,7 +81,7 @@ func printToPager(w io.Writer, buf *bytes.Buffer) (err error) { } } } - pager := exec.Command(envPager, "-R") + pager := exec.Command("/bin/sh", "-c", envPager, "-R") pager.Stdin = buf pager.Stdout = w err = pager.Run() @@ -239,7 +239,7 @@ func doesCommandExist(cmdName string) bool { if cmdName == "" { return false } - cmd := exec.Command("command", "-v", cmdName) + cmd := exec.Command("/bin/sh", "-c", "command -v "+cmdName) if err := cmd.Run(); err != nil { return false } diff --git a/cmd/print_test.go b/cmd/print_test.go index 8195b1fa7..c73cadc67 100644 --- a/cmd/print_test.go +++ b/cmd/print_test.go @@ -1,6 +1,7 @@ package cmd import ( + "runtime" "testing" ) @@ -29,10 +30,12 @@ func TestPrintByteInfo(t *testing.T) { } func TestDoesCommandExist(t *testing.T) { - if doesCommandExist("ls") == false { - t.Error("ls command does not exist!") - } - if doesCommandExist("ls111") == true { - t.Error("ls111 command should not exist!") + if runtime.GOOS == "darwin" || runtime.GOOS == "linux" { + if doesCommandExist("ls") == false { + t.Error("ls command does not exist!") + } + if doesCommandExist("ls111") == true { + t.Error("ls111 command should not exist!") + } } }