MCPcopy Index your code
hub / github.com/docker/docker-agent / DetectWindowsShell

Function DetectWindowsShell

pkg/shellpath/shellpath.go:51–59  ·  view source on GitHub ↗

DetectWindowsShell returns the shell binary and argument prefix for Windows. It prefers PowerShell (resolved via LookPath, which returns an absolute path), falling back to cmd.exe via [WindowsCmdExe].

()

Source from the content-addressed store, hash-verified

49// It prefers PowerShell (resolved via LookPath, which returns an absolute path),
50// falling back to cmd.exe via [WindowsCmdExe].
51func DetectWindowsShell() (shell string, argsPrefix []string) {
52 powershellArgs := []string{"-NoProfile", "-NonInteractive", "-Command"}
53 for _, ps := range []string{"pwsh.exe", "powershell.exe"} {
54 if path, err := exec.LookPath(ps); err == nil {
55 return path, powershellArgs
56 }
57 }
58 return WindowsCmdExe(), []string{"/C"}
59}
60
61// DetectUnixShell returns the user's shell from the SHELL environment variable,
62// falling back to /bin/sh.

Callers 2

DetectShellFunction · 0.85

Calls 1

WindowsCmdExeFunction · 0.85