aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/mattn/go-shellwords/util_go15.go
blob: 180f00f0bd6abf021a058bc5d9344fd39802998f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// +build !go1.6

package shellwords

import (
	"os"
	"os/exec"
	"runtime"
	"strings"
)

func shellRun(line string) (string, error) {
	var b []byte
	var err error
	if runtime.GOOS == "windows" {
		b, err = exec.Command(os.Getenv("COMSPEC"), "/c", line).Output()
	} else {
		b, err = exec.Command(os.Getenv("SHELL"), "-c", line).Output()
	}
	if err != nil {
		return "", err
	}
	return strings.TrimSpace(string(b)), nil
}