support ksh for mc's subshell (^O to swap between shell and mc)
ok robert@ (maintainer)
This commit is contained in:
parent
93078ee380
commit
1462359a80
|
@ -1,6 +1,7 @@
|
|||
COMMENT= free Norton Commander clone with many useful features
|
||||
|
||||
DISTNAME= mc-4.8.28
|
||||
REVISION= 0
|
||||
CATEGORIES= misc
|
||||
|
||||
HOMEPAGE= https://www.midnight-commander.org/
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
Index: lib/fileloc.h
|
||||
--- lib/fileloc.h.orig
|
||||
+++ lib/fileloc.h
|
||||
@@ -53,6 +53,7 @@
|
||||
|
||||
#define MC_BASHRC_FILE "bashrc"
|
||||
#define MC_ZSHRC_FILE ".zshrc"
|
||||
+#define MC_KSHRC_FILE "kshrc"
|
||||
#define MC_ASHRC_FILE "ashrc"
|
||||
#define MC_INPUTRC_FILE "inputrc"
|
||||
#define MC_CONFIG_FILE "ini"
|
|
@ -0,0 +1,11 @@
|
|||
Index: lib/mcconfig/paths.c
|
||||
--- lib/mcconfig/paths.c.orig
|
||||
+++ lib/mcconfig/paths.c
|
||||
@@ -75,6 +75,7 @@ static const struct
|
||||
{ &mc_data_str, MC_SKINS_DIR },
|
||||
{ &mc_data_str, FISH_PREFIX },
|
||||
{ &mc_data_str, MC_ASHRC_FILE },
|
||||
+ { &mc_data_str, MC_KSHRC_FILE },
|
||||
{ &mc_data_str, MC_BASHRC_FILE },
|
||||
{ &mc_data_str, MC_INPUTRC_FILE },
|
||||
{ &mc_data_str, MC_ZSHRC_FILE },
|
|
@ -0,0 +1,24 @@
|
|||
Index: lib/shell.c
|
||||
--- lib/shell.c.orig
|
||||
+++ lib/shell.c
|
||||
@@ -72,6 +72,8 @@ mc_shell_get_installed_in_system (void)
|
||||
mc_shell->path = g_strdup ("/bin/dash");
|
||||
else if (access ("/bin/busybox", X_OK) == 0)
|
||||
mc_shell->path = g_strdup ("/bin/busybox");
|
||||
+ else if (access ("/bin/ksh", X_OK) == 0)
|
||||
+ mc_shell->path = g_strdup ("/bin/ksh");
|
||||
else if (access ("/bin/zsh", X_OK) == 0)
|
||||
mc_shell->path = g_strdup ("/bin/zsh");
|
||||
else if (access ("/bin/tcsh", X_OK) == 0)
|
||||
@@ -201,6 +203,11 @@ mc_shell_recognize_path (mc_shell_t * mc_shell)
|
||||
{
|
||||
mc_shell->type = SHELL_BASH;
|
||||
mc_shell->name = "bash";
|
||||
+ }
|
||||
+ else if (strstr (mc_shell->path, "/ksh") != NULL || getenv ("KSH_VERSION") != NULL)
|
||||
+ {
|
||||
+ mc_shell->type = SHELL_KSH;
|
||||
+ mc_shell->name = "ksh";
|
||||
}
|
||||
else if (strstr (mc_shell->path, "/sh") != NULL || getenv ("SH") != NULL)
|
||||
{
|
|
@ -0,0 +1,13 @@
|
|||
Index: lib/shell.h
|
||||
--- lib/shell.h.orig
|
||||
+++ lib/shell.h
|
||||
@@ -18,7 +18,8 @@ typedef enum
|
||||
SHELL_DASH, /* Debian variant of ash */
|
||||
SHELL_TCSH,
|
||||
SHELL_ZSH,
|
||||
- SHELL_FISH
|
||||
+ SHELL_FISH,
|
||||
+ SHELL_KSH
|
||||
} shell_type_t;
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
|
@ -0,0 +1,41 @@
|
|||
Index: src/subshell/common.c
|
||||
--- src/subshell/common.c.orig
|
||||
+++ src/subshell/common.c
|
||||
@@ -378,6 +378,21 @@ init_subshell_child (const char *pty_name)
|
||||
}
|
||||
break;
|
||||
|
||||
+ case SHELL_KSH:
|
||||
+ /* Do we have a custom init file ~/.local/share/mc/kshrc? */
|
||||
+ init_file = mc_config_get_full_path (MC_KSHRC_FILE);
|
||||
+
|
||||
+ /* Otherwise use ~/.kshrc */
|
||||
+ if (!exist_file (init_file))
|
||||
+ {
|
||||
+ g_free (init_file);
|
||||
+ init_file = g_strdup (".kshrc");
|
||||
+ }
|
||||
+
|
||||
+ /* Put init file to ENV variable used by ksh */
|
||||
+ g_setenv ("ENV", init_file, TRUE);
|
||||
+ break;
|
||||
+
|
||||
/* TODO: Find a way to pass initfile to TCSH and FISH */
|
||||
case SHELL_TCSH:
|
||||
case SHELL_FISH:
|
||||
@@ -427,6 +442,7 @@ init_subshell_child (const char *pty_name)
|
||||
|
||||
case SHELL_ASH_BUSYBOX:
|
||||
case SHELL_DASH:
|
||||
+ case SHELL_KSH:
|
||||
case SHELL_TCSH:
|
||||
case SHELL_FISH:
|
||||
execl (mc_global.shell->path, mc_global.shell->path, (char *) NULL);
|
||||
@@ -1133,6 +1149,7 @@ init_subshell_precmd (char *precmd, size_t buff_size)
|
||||
* "PRECMD=precmd; "
|
||||
* "PS1='$($PRECMD)$ '\n",
|
||||
*/
|
||||
+ case SHELL_KSH:
|
||||
g_snprintf (precmd, buff_size,
|
||||
"precmd() { "
|
||||
"if [ ! \"${PWD##$HOME}\" ]; then "
|
Loading…
Reference in New Issue