From 7bd70db83b327cb4a5c5718ea7dc4b3f474c07a6 Mon Sep 17 00:00:00 2001 From: Evan Hazlett Date: Tue, 9 Jun 2015 13:18:15 -0400 Subject: [PATCH] windows: error message if using powershell/cmd and none specified Signed-off-by: Evan Hazlett --- commands/commands.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/commands/commands.go b/commands/commands.go index 906e79ae1f..bcfc9aeb15 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -652,14 +652,18 @@ func getCertPathInfo(c *cli.Context) libmachine.CertPathInfo { } func detectShell() (string, error) { - // attempt to get the SHELL env var - shell := filepath.Base(os.Getenv("SHELL")) - // none detected; check for windows env and not bash (i.e. msysgit, etc) - if runtime.GOOS == "windows" && shell == "" { + // check for windows env and not bash (i.e. msysgit, etc) + // the SHELL env var is not set for processes in msysgit; we check + // for TERM instead + if runtime.GOOS == "windows" && os.Getenv("TERM") != "cygwin" { log.Printf("On Windows, please specify either 'cmd' or 'powershell' with the --shell flag.\n\n") return "", ErrUnknownShell } + // attempt to get the SHELL env var + shell := filepath.Base(os.Getenv("SHELL")) + + log.Debugf("shell: %s", shell) if shell == "" { return "", ErrUnknownShell }