terraform/vendor/github.com/mattn/go-shellwords/util_posix.go

23 lines
409 B
Go
Raw Normal View History

// +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 {
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
}