blob: ddcbf229e6d25003ca5edeff4b3e3b914d0c1527 (
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
25
26
27
28
29
|
// +build !go1.6
package shellwords
import (
"os"
"os/exec"
"runtime"
"strings"
)
func shellRun(line, dir string) (string, error) {
var b []byte
var err error
var cmd *exec.Cmd
if runtime.GOOS == "windows" {
cmd = exec.Command(os.Getenv("COMSPEC"), "/c", line)
} else {
cmd = exec.Command(os.Getenv("SHELL"), "-c", line)
}
if dir != "" {
cmd.Dir = dir
}
b, err = cmd.Output()
if err != nil {
return "", err
}
return strings.TrimSpace(string(b)), nil
}
|