open-nomad/vendor/github.com/mattn/go-shellwords/util_posix.go

20 lines
335 B
Go
Raw Normal View History

2016-10-03 20:50:56 +00:00
// +build !windows
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 {
return "", errors.New(err.Error() + ":" + string(b))
}
return strings.TrimSpace(string(b)), nil
}