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)
| 906 | // interactive shell. The command is owned by tea.ExecProcess, not by any |
| 907 | // request-scoped context, so exec.Command is intentional. |
| 908 | func 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). |
no test coverage detected