2017-03-12 17:18:59 -03:00
|
|
|
// +build windows
|
|
|
|
|
|
|
|
|
|
package execext
|
|
|
|
|
|
|
|
|
|
import (
|
2017-04-12 20:32:56 -03:00
|
|
|
"context"
|
2017-03-12 17:18:59 -03:00
|
|
|
"os/exec"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// NewCommand returns a new command that runs on "sh" is available or on "cmd"
|
|
|
|
|
// otherwise on Windows
|
2017-04-12 20:32:56 -03:00
|
|
|
func NewCommand(ctx context.Context, c string) *exec.Cmd {
|
2017-03-12 17:18:59 -03:00
|
|
|
if ShExists {
|
2017-04-12 20:32:56 -03:00
|
|
|
return newShCommand(ctx, c)
|
2017-03-12 17:18:59 -03:00
|
|
|
}
|
2017-04-12 20:32:56 -03:00
|
|
|
return newCmdCommand(ctx, c)
|
2017-03-12 17:18:59 -03:00
|
|
|
}
|
|
|
|
|
|
2017-04-12 20:32:56 -03:00
|
|
|
func newCmdCommand(ctx context.Context, c string) *exec.Cmd {
|
|
|
|
|
return exec.CommandContext(ctx, "cmd", "/C", c)
|
2017-03-12 17:18:59 -03:00
|
|
|
}
|