Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions otelcli/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"os/exec"
"runtime"
"strings"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -61,8 +62,17 @@ func doExec(cmd *cobra.Command, args []string) {
Value: attribute.StringValue(commandString),
})

// should this also work on Windows? for now, assume not
child := exec.Command("/bin/sh", "-c", commandString)
// use cmd.exe to launch PowerShell on Windows
var shell string
if runtime.GOOS == "windows" {
shell = "cmd.exe"
commandString = "/C powershell " + commandString
} else {
shell = "/bin/sh"
}

child := exec.Command(shell, "-c", commandString)

// attach all stdio to the parent's handles
child.Stdin = os.Stdin
child.Stdout = os.Stdout
Expand Down