mirror of https://github.com/mickael-menu/zk
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.
19 lines
367 B
Go
19 lines
367 B
Go
4 years ago
|
// +build !windows
|
||
|
|
||
|
package exec
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
"os/exec"
|
||
|
)
|
||
|
|
||
|
// CommandFromString returns a Cmd running the given command with $SHELL.
|
||
4 years ago
|
func CommandFromString(command string, args ...string) *exec.Cmd {
|
||
4 years ago
|
shell := os.Getenv("SHELL")
|
||
|
if len(shell) == 0 {
|
||
|
shell = "sh"
|
||
|
}
|
||
4 years ago
|
args = append([]string{"-c", command, "--"}, args...)
|
||
4 years ago
|
return exec.Command(shell, args...)
|
||
4 years ago
|
}
|