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

Function DetectShell

pkg/shellpath/shellpath.go:40–46  ·  view source on GitHub ↗

DetectShell returns the appropriate shell binary and its argument prefix for the current platform. On Windows, it prefers PowerShell (pwsh.exe or powershell.exe) resolved via exec.LookPath (which returns an absolute path on success), falling back to cmd.exe resolved through [WindowsCmdExe]. On Uni

()

Source from the content-addressed store, hash-verified

38//
39// On Unix, it uses the SHELL environment variable or /bin/sh.
40func DetectShell() (shell string, argsPrefix []string) {
41 if runtime.GOOS == "windows" {
42 return DetectWindowsShell()
43 }
44
45 return defaultUnixShell(), []string{"-c"}
46}
47
48// DetectWindowsShell returns the shell binary and argument prefix for Windows.
49// It prefers PowerShell (resolved via LookPath, which returns an absolute path),

Callers 9

detectShellFunction · 0.92
executeMethod · 0.92
runPostEditCommandsFunction · 0.92
RunBangCommandMethod · 0.92
runCommandFunction · 0.92
newCommandFactoryFunction · 0.92
runEventHookFunction · 0.92
TestDetectShell_UnixFunction · 0.85

Calls 2

DetectWindowsShellFunction · 0.85
defaultUnixShellFunction · 0.85

Tested by 2

TestDetectShell_UnixFunction · 0.68