zk/util/exec/exec_unix.go

19 lines
361 B
Go
Raw Normal View History

// +build !windows
package exec
import (
"os"
"os/exec"
)
// CommandFromString returns a Cmd running the given command with $SHELL.
2021-01-24 11:10:13 +00:00
func CommandFromString(command string, args ...string) *exec.Cmd {
shell := os.Getenv("SHELL")
if len(shell) == 0 {
shell = "sh"
}
2021-01-24 11:10:13 +00:00
args = append([]string{"-c", command}, args...)
return exec.Command(shell, args...)
}