Skip Shell check on Windows (#3973)

Fixes `mc: <ERROR> Failed to enable autocompletion. Cannot 
determine shell-type and SHELL environment variable found: exit status 1.` 
on Windows.
This commit is contained in:
Klaus Post
2022-02-10 17:52:02 -08:00
committed by GitHub
parent 548dc0fd99
commit e71b1c80b4
+12 -11
View File
@@ -302,18 +302,19 @@ func initMC() {
func getShellName() (string, bool) {
shellName := os.Getenv("SHELL")
if shellName == "" {
ppid := os.Getppid()
cmd := exec.Command("ps", "-p", strconv.Itoa(ppid), "-o", "comm=")
ppName, err := cmd.Output()
if err != nil {
fatalIf(probe.NewError(err), "Failed to enable autocompletion. Cannot determine shell type and"+
"no SHELL environment variable found")
}
shellName = strings.TrimSpace(string(ppName))
return strings.ToLower(filepath.Base(shellName)), false
if shellName != "" || runtime.GOOS == "windows" {
return strings.ToLower(filepath.Base(shellName)), true
}
return strings.ToLower(filepath.Base(shellName)), true
ppid := os.Getppid()
cmd := exec.Command("ps", "-p", strconv.Itoa(ppid), "-o", "comm=")
ppName, err := cmd.Output()
if err != nil {
fatalIf(probe.NewError(err), "Failed to enable autocompletion. Cannot determine shell type and "+
"no SHELL environment variable found")
}
shellName = strings.TrimSpace(string(ppName))
return strings.ToLower(filepath.Base(shellName)), false
}
func installAutoCompletion() {