util_posix.go 335 B

1234567891011121314151617181920
  1. // +build !windows
  2. package shellwords
  3. import (
  4. "errors"
  5. "os"
  6. "os/exec"
  7. "strings"
  8. )
  9. func shellRun(line string) (string, error) {
  10. shell := os.Getenv("SHELL")
  11. b, err := exec.Command(shell, "-c", line).Output()
  12. if err != nil {
  13. return "", errors.New(err.Error() + ":" + string(b))
  14. }
  15. return strings.TrimSpace(string(b)), nil
  16. }