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:
+12
-11
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user