Merge pull request #1341 from ehazlett/windows-prompt-for-env

windows: error message if using powershell/cmd and none specified
This commit is contained in:
Nathan LeClaire 2015-06-10 13:49:21 -07:00
commit 061f865c3e
1 changed files with 8 additions and 4 deletions

View File

@ -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
}