mirror of https://github.com/k3s-io/k3s
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
409 B
23 lines
409 B
6 years ago
|
// +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
|
||
|
}
|