mirror of
https://github.com/peco/peco.git
synced 2026-09-10 07:16:29 -04:00
23 lines
420 B
Go
23 lines
420 B
Go
//go:build !windows
|
|
|
|
package util
|
|
|
|
import (
|
|
"context"
|
|
"os/exec"
|
|
)
|
|
|
|
// Shell creates an exec.Cmd that runs the given command strings via /bin/sh -c.
|
|
func Shell(ctx context.Context, cmd ...string) *exec.Cmd {
|
|
const shellpath = `/bin/sh`
|
|
const shellopt = `-c`
|
|
|
|
args := make([]string, len(cmd)+1)
|
|
args[0] = shellopt
|
|
for i := range cmd {
|
|
args[i+1] = cmd[i]
|
|
}
|
|
|
|
return exec.CommandContext(ctx, shellpath, args...)
|
|
}
|