aboutsummaryrefslogtreecommitdiff
path: root/utils/mc/patches/030-mc-mksh-subshell-v2.patch
blob: 37274c14c10b3313454b32e4709aafbb8e9b73e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
--- a/lib/shell.c
+++ b/lib/shell.c
@@ -70,6 +70,8 @@ mc_shell_get_installed_in_system (void)
         mc_shell->path = g_strdup ("/bin/bash");
     else if (access ("/bin/ash", X_OK) == 0)
         mc_shell->path = g_strdup ("/bin/ash");
+    else if (access ("/bin/mksh", X_OK) == 0)
+        mc_shell->path = g_strdup ("/bin/mksh");
     else if (access ("/bin/dash", X_OK) == 0)
         mc_shell->path = g_strdup ("/bin/dash");
     else if (access ("/bin/busybox", X_OK) == 0)
@@ -151,6 +153,12 @@ mc_shell_recognize_real_path (mc_shell_t
         mc_shell->type = SHELL_ZSH;
         mc_shell->name = "zsh";
     }
+    else if (strstr (mc_shell->path, "/mksh") != NULL
+             || strstr (mc_shell->real_path, "/mksh") != NULL)
+    {
+        mc_shell->type = SHELL_MKSH;
+        mc_shell->name = "mksh";
+    }
     else if (strstr (mc_shell->path, "/tcsh") != NULL
              || strstr (mc_shell->real_path, "/tcsh") != NULL)
     {
--- a/lib/shell.h
+++ b/lib/shell.h
@@ -16,6 +16,7 @@ typedef enum
     SHELL_BASH,
     SHELL_ASH_BUSYBOX,          /* BusyBox default shell (ash) */
     SHELL_DASH,                 /* Debian variant of ash */
+    SHELL_MKSH,
     SHELL_TCSH,
     SHELL_ZSH,
     SHELL_FISH
--- a/src/subshell/common.c
+++ b/src/subshell/common.c
@@ -380,6 +380,11 @@ init_subshell_child (const char *pty_nam
         }
         break;
 
+    case SHELL_MKSH:
+        init_file = g_strdup (".shrc");
+        g_setenv ("ENV", init_file, TRUE);
+        break;
+
         /* TODO: Find a way to pass initfile to TCSH and FISH */
     case SHELL_TCSH:
     case SHELL_FISH:
@@ -429,6 +434,7 @@ init_subshell_child (const char *pty_nam
 
     case SHELL_ASH_BUSYBOX:
     case SHELL_DASH:
+    case SHELL_MKSH:
     case SHELL_TCSH:
     case SHELL_FISH:
         execl (mc_global.shell->path, mc_global.shell->path, (char *) NULL);
@@ -1094,6 +1100,10 @@ init_subshell_precmd (char *precmd, size
                     "PS1='\\u@\\h:\\w\\$ '\n", command_buffer_pipe[WRITE],
                     command_buffer_pipe[WRITE], subshell_pipe[WRITE]);
         break;
+    case SHELL_MKSH:
+        g_snprintf (precmd, buff_size,
+                "PS1='$(pwd>&%d; kill -STOP $$)'\"$((( USER_ID )) && print '$ ' || print '# ')\"\n", subshell_pipe[WRITE]);
+        break;
 
     case SHELL_ASH_BUSYBOX:
         /* BusyBox ash needs a somewhat complicated precmd emulation via PS1, and it is vital