Ticket #3748: mc-mksh-subshell-v2.patch

File mc-mksh-subshell-v2.patch, 2.8 KB (added by gloomyquazar, 7 years ago)
  • lib/shell.c

    diff -Naur mc-4.8.18.orig/lib/shell.c mc-4.8.18/lib/shell.c
    old new  
    6666    /* 3rd choice: look for existing shells supported as MC subshells.  */ 
    6767    if (access ("/bin/bash", X_OK) == 0) 
    6868        mc_shell->path = g_strdup ("/bin/bash"); 
     69    else if (access ("/usr/local/bin/mksh", X_OK) == 0) 
     70        mc_shell->path = g_strdup ("/usr/local/bin/mksh"); 
     71    else if (access ("/bin/mksh", X_OK) == 0) 
     72        mc_shell->path = g_strdup ("/bin/mksh"); 
    6973    else if (access ("/bin/ash", X_OK) == 0) 
    7074        mc_shell->path = g_strdup ("/bin/ash"); 
    7175    else if (access ("/bin/dash", X_OK) == 0) 
     
    149153        mc_shell->type = SHELL_ZSH; 
    150154        mc_shell->name = "zsh"; 
    151155    } 
     156    else if (strstr (mc_shell->path, "/mksh") != NULL 
     157             || strstr (mc_shell->real_path, "/mksh") != NULL) 
     158    { 
     159        mc_shell->type = SHELL_MKSH; 
     160        mc_shell->name = "mksh"; 
     161    } 
    152162    else if (strstr (mc_shell->path, "/tcsh") != NULL 
    153163             || strstr (mc_shell->real_path, "/tcsh") != NULL) 
    154164    { 
  • lib/shell.h

    diff -Naur mc-4.8.18.orig/lib/shell.h mc-4.8.18/lib/shell.h
    old new  
    1212typedef enum 
    1313{ 
    1414    SHELL_NONE, 
     15    SHELL_MKSH, 
    1516    SHELL_SH, 
    1617    SHELL_BASH, 
    1718    SHELL_ASH_BUSYBOX,          /* BusyBox default shell (ash) */ 
  • src/subshell/common.c

    diff -Naur mc-4.8.18.orig/src/subshell/common.c mc-4.8.18/src/subshell/common.c
    old new  
    320320 
    321321        break; 
    322322 
     323    case SHELL_MKSH: 
     324        init_file = g_strdup (".shrc"); 
     325        putenv_str = g_strconcat ("ENV=", init_file, (char *) NULL); 
     326        putenv (putenv_str); 
     327        break; 
     328 
    323329        /* TODO: Find a way to pass initfile to TCSH, ZSH and FISH */ 
    324330    case SHELL_TCSH: 
    325331    case SHELL_ZSH: 
     
    367373 
    368374    case SHELL_ASH_BUSYBOX: 
    369375    case SHELL_DASH: 
     376    case SHELL_MKSH: 
    370377    case SHELL_TCSH: 
    371378    case SHELL_FISH: 
    372379        execl (mc_global.shell->path, mc_global.shell->path, (char *) NULL); 
     
    801808                    "PS1='\\u@\\h:\\w\\$ '\n", subshell_pipe[WRITE]); 
    802809        break; 
    803810 
     811    case SHELL_MKSH: 
     812        g_snprintf (precmd, buff_size, 
     813                    "PS1='$(pwd>&%d; kill -STOP $$)'\"$((( USER_ID )) && print '$ ' || print '# ')\"\n", subshell_pipe[WRITE]); 
     814        break; 
     815 
    804816    case SHELL_ASH_BUSYBOX: 
    805817        /* BusyBox ash needs a somewhat complicated precmd emulation via PS1, and it is vital 
    806818         * that BB be built with active CONFIG_ASH_EXPAND_PRMT, but this is the default anyway.