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

Function newInteractiveShellCmd

pkg/tui/handlers.go:908–923  ·  view source on GitHub ↗

newInteractiveShellCmd returns a command that launches the user's preferred interactive shell. The command is owned by tea.ExecProcess, not by any request-scoped context, so exec.Command is intentional.

(exitMsg string)

Source from the content-addressed store, hash-verified

906// interactive shell. The command is owned by tea.ExecProcess, not by any
907// request-scoped context, so exec.Command is intentional.
908func newInteractiveShellCmd(exitMsg string) *exec.Cmd {
909 if goruntime.GOOS != "windows" {
910 shell := shellpath.DetectUnixShell()
911 return execCmd(shell, "-i", "-c", `echo -e "\n`+exitMsg+`"; exec `+shell)
912 }
913
914 psArgs := []string{"-NoLogo", "-NoExit", "-Command", `Write-Host ""; Write-Host "` + exitMsg + `"`}
915 if path, err := exec.LookPath("pwsh.exe"); err == nil {
916 return execCmd(path, psArgs...)
917 }
918 if path, err := exec.LookPath("powershell.exe"); err == nil {
919 return execCmd(path, psArgs...)
920 }
921 // Use absolute path to cmd.exe to prevent PATH hijacking (CWE-426).
922 return execCmd(shellpath.WindowsCmdExe(), "/K", "echo. & echo "+exitMsg)
923}
924
925// execCmd is a thin wrapper around exec.Command used for interactive
926// processes whose lifecycle is owned by tea.ExecProcess (not a context).

Callers 1

startShellMethod · 0.85

Calls 3

DetectUnixShellFunction · 0.92
WindowsCmdExeFunction · 0.92
execCmdFunction · 0.85

Tested by

no test coverage detected