2019-02-22 17:54:29 +01:00
|
|
|
// +build !windows,go1.6
|
2017-02-13 23:10:01 +01:00
|
|
|
|
|
|
|
package shellwords
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
func shellRun(line string) (string, error) {
|
|
|
|
shell := os.Getenv("SHELL")
|
|
|
|
b, err := exec.Command(shell, "-c", line).Output()
|
|
|
|
if err != nil {
|
2019-02-22 17:54:29 +01:00
|
|
|
if eerr, ok := err.(*exec.ExitError); ok {
|
|
|
|
b = eerr.Stderr
|
|
|
|
}
|
2017-02-13 23:10:01 +01:00
|
|
|
return "", errors.New(err.Error() + ":" + string(b))
|
|
|
|
}
|
|
|
|
return strings.TrimSpace(string(b)), nil
|
|
|
|
}
|