2020-05-30 14:29:47 +00:00
|
|
|
// +build !windows,go1.6
|
2016-10-03 20:50:56 +00: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 {
|
2020-05-30 14:29:47 +00:00
|
|
|
if eerr, ok := err.(*exec.ExitError); ok {
|
|
|
|
b = eerr.Stderr
|
|
|
|
}
|
2016-10-03 20:50:56 +00:00
|
|
|
return "", errors.New(err.Error() + ":" + string(b))
|
|
|
|
}
|
|
|
|
return strings.TrimSpace(string(b)), nil
|
|
|
|
}
|