You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zk/internal/util/exec/exec_unix.go

21 lines
444 B
Go

// +build !windows
package exec
import (
"os/exec"
osutil "github.com/zk-org/zk/internal/util/os"
)
// CommandFromString returns a Cmd running the given command with $SHELL.
func CommandFromString(command string, args ...string) *exec.Cmd {
shell := osutil.GetOptEnv("ZK_SHELL").
Or(osutil.GetOptEnv("SHELL")).
OrString("sh").
Unwrap()
args = append([]string{"-c", command, "--"}, args...)
return exec.Command(shell, args...)
}