Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Powershell in CMD being mis-detected #34

Merged
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
4 changes: 3 additions & 1 deletion libmachine/shell/shell_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ func getNameAndItsPpid(pid int) (exefile string, parentid int, err error) {
func Detect() (string, error) {
shell := os.Getenv("SHELL")

if shell == "" {
// if you spawn a Powershell instance from CMD, sometimes the SHELL environment variable still points to CMD in the Powershell instance
// so if SHELL is pointing to CMD, let's do extra work to get the correct shell
if shell == "" || filepath.Base(shell) == "cmd" {
shell, shellppid, err := getNameAndItsPpid(os.Getppid())
if err != nil {
return "cmd", err // defaulting to cmd
Expand Down