Skip to content

Commit

Permalink
fix(shell): use correct exec per os
Browse files Browse the repository at this point in the history
  • Loading branch information
tbckr committed Sep 26, 2023
1 parent 5723bfd commit 361f8ed
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"io"
"os"
"os/exec"
"runtime"
)

func IsPipedShell() (bool, error) {
Expand Down Expand Up @@ -73,7 +74,18 @@ func getUserConfirmation(input io.Reader, output io.Writer) (bool, error) {
}

func executeShellCommand(ctx context.Context, output io.Writer, command string) error {
cmd := exec.CommandContext(ctx, "bash", "-c", command)
var executeCommand string
var args []string
switch runtime.GOOS {
case "windows":
executeCommand = "cmd"
args = []string{"/C", command}

Check warning on line 82 in shell/shell.go

View check run for this annotation

Codecov / codecov/patch

shell/shell.go#L80-L82

Added lines #L80 - L82 were not covered by tests
default:
executeCommand = "bash"
args = []string{"-c", command}
}

cmd := exec.CommandContext(ctx, executeCommand, args...)
cmd.Stdout = output
err := cmd.Run()
if err != nil {
Expand Down

0 comments on commit 361f8ed

Please sign in to comment.