Skip to content

Commit

Permalink
On Windows, move from cmd.exe to powershell.exe for command invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
shaneharter committed Apr 27, 2022
1 parent 7ad1677 commit b8c774a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions cmd/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"github.com/kballard/go-shellquote"
"github.com/spf13/cobra"
flag "github.com/spf13/pflag"
"io"
"io/ioutil"
"os"
Expand All @@ -16,8 +17,6 @@ import (
"sync"
"syscall"
"time"
flag "github.com/spf13/pflag"

)

var monitorCode string
Expand Down Expand Up @@ -237,7 +236,7 @@ func makeCronLikeEnv() []string {
func makeSubcommandExec(subcommand string) *exec.Cmd {
var execCmd *exec.Cmd
if runtime.GOOS == "windows" {
execCmd = exec.Command("cmd", "/c", subcommand)
execCmd = exec.Command("powershell.exe", "-Command", subcommand)
} else if _, err := os.Stat("/bin/bash"); err == nil {
execCmd = exec.Command("bash", "-c", subcommand)
} else {
Expand Down

0 comments on commit b8c774a

Please sign in to comment.