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

package shellwords

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

func shellRun(line string) (string, error) {
	shell := os.Getenv("COMSPEC")
	b, err := exec.Command(shell, "/c", line).Output()
	if err != nil {
		if eerr, ok := err.(*exec.ExitError); ok {
			b = eerr.Stderr
		}
		return "", errors.New(err.Error() + ":" + string(b))
	}
	return strings.TrimSpace(string(b)), nil
}