mc-mksh-subshell-v2.patch 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # Support mksh for mc subshell
  2. # https://midnight-commander.org/ticket/3748
  3. diff -Naur mc-4.8.18.orig/lib/shell.c mc-4.8.18/lib/shell.c
  4. --- mc-4.8.18.orig/lib/shell.c 2016-09-22 18:24:12.000000000 +0000
  5. +++ mc-4.8.18/lib/shell.c 2017-02-16 13:47:34.933939000 +0000
  6. @@ -66,6 +66,8 @@
  7. /* 3rd choice: look for existing shells supported as MC subshells. */
  8. if (access ("/bin/bash", X_OK) == 0)
  9. mc_shell->path = g_strdup ("/bin/bash");
  10. + else if (access ("/bin/mksh", X_OK) == 0)
  11. + mc_shell->path = g_strdup ("/bin/mksh");
  12. else if (access ("/bin/ash", X_OK) == 0)
  13. mc_shell->path = g_strdup ("/bin/ash");
  14. else if (access ("/bin/dash", X_OK) == 0)
  15. @@ -149,6 +153,12 @@
  16. mc_shell->type = SHELL_ZSH;
  17. mc_shell->name = "zsh";
  18. }
  19. + else if (strstr (mc_shell->path, "/mksh") != NULL
  20. + || strstr (mc_shell->real_path, "/mksh") != NULL)
  21. + {
  22. + mc_shell->type = SHELL_MKSH;
  23. + mc_shell->name = "mksh";
  24. + }
  25. else if (strstr (mc_shell->path, "/tcsh") != NULL
  26. || strstr (mc_shell->real_path, "/tcsh") != NULL)
  27. {
  28. diff -Naur mc-4.8.18.orig/lib/shell.h mc-4.8.18/lib/shell.h
  29. --- mc-4.8.18.orig/lib/shell.h 2016-03-12 15:45:47.000000000 +0000
  30. +++ mc-4.8.18/lib/shell.h 2017-02-15 21:57:39.000000000 +0000
  31. @@ -12,6 +12,7 @@
  32. typedef enum
  33. {
  34. SHELL_NONE,
  35. + SHELL_MKSH,
  36. SHELL_SH,
  37. SHELL_BASH,
  38. SHELL_ASH_BUSYBOX, /* BusyBox default shell (ash) */
  39. diff -Naur mc-4.8.18.orig/src/subshell/common.c mc-4.8.18/src/subshell/common.c
  40. --- mc-4.8.18.orig/src/subshell/common.c 2016-09-22 18:24:12.000000000 +0000
  41. +++ mc-4.8.18/src/subshell/common.c 2017-02-20 18:48:22.681514000 +0000
  42. @@ -320,6 +320,12 @@
  43. break;
  44. + case SHELL_MKSH:
  45. + init_file = g_strdup (".shrc");
  46. + putenv_str = g_strconcat ("ENV=", init_file, (char *) NULL);
  47. + putenv (putenv_str);
  48. + break;
  49. +
  50. /* TODO: Find a way to pass initfile to TCSH, ZSH and FISH */
  51. case SHELL_TCSH:
  52. case SHELL_ZSH:
  53. @@ -367,6 +373,7 @@
  54. case SHELL_ASH_BUSYBOX:
  55. case SHELL_DASH:
  56. + case SHELL_MKSH:
  57. case SHELL_TCSH:
  58. case SHELL_FISH:
  59. execl (mc_global.shell->path, mc_global.shell->path, (char *) NULL);
  60. @@ -801,6 +808,11 @@
  61. "PS1='\\u@\\h:\\w\\$ '\n", subshell_pipe[WRITE]);
  62. break;
  63. + case SHELL_MKSH:
  64. + g_snprintf (precmd, buff_size,
  65. + "PS1='$(pwd>&%d; kill -STOP $$)'\"$((( USER_ID )) && print '$ ' || print '# ')\"\n", subshell_pipe[WRITE]);
  66. + break;
  67. +
  68. case SHELL_ASH_BUSYBOX:
  69. /* BusyBox ash needs a somewhat complicated precmd emulation via PS1, and it is vital
  70. * that BB be built with active CONFIG_ASH_EXPAND_PRMT, but this is the default anyway.