1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/vendor/github.com/mattn/go-shellwords/util_posix.go
Sebastiaan van Stijn 8b3759eae1
bump mattn/go-shellwords v1.0.5
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-04-10 00:16:41 +02:00

22 lines
409 B
Go

// +build !windows,go1.6
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 {
if eerr, ok := err.(*exec.ExitError); ok {
b = eerr.Stderr
}
return "", errors.New(err.Error() + ":" + string(b))
}
return strings.TrimSpace(string(b)), nil
}