Skip to content

Commit

Permalink
Merge pull request #34 from spowelljr/fixPowershellDetection
Browse files Browse the repository at this point in the history
Fix Powershell in CMD being mis-detected
  • Loading branch information
afbjorklund committed Jul 18, 2021
2 parents fcb2ad5 + 8b02959 commit 753b247
Showing 1 changed file with 3 additions and 1 deletion.
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

0 comments on commit 753b247

Please sign in to comment.