diff --git a/src/subshell/common.c b/src/subshell/common.c index 1c432fd7e4..4827da0446 100644 --- a/src/subshell/common.c +++ b/src/subshell/common.c @@ -1714,6 +1714,18 @@ do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt) return; } } + + /* A quick and dirty fix for fish shell. For some reason, fish does not + * execute all the commands sent to it from Midnight Commander :( + * An example of such buggy behavior is presented in ticket #4521. + * TODO: Find the real cause and fix it "the right way" */ + if (mc_global.shell->type == SHELL_FISH) + { + write_all (mc_global.tty.subshell_pty, "\n", 1); + subshell_state = RUNNING_COMMAND; + feed_subshell (QUIETLY, TRUE); + } + /* The initial space keeps this out of the command history (in bash because we set "HISTCONTROL=ignorespace") */ write_all (mc_global.tty.subshell_pty, " cd ", 4); @@ -1778,12 +1790,16 @@ do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt) } } - /* Really escape Zsh history */ - if (mc_global.shell->type == SHELL_ZSH) + /* Really escape Zsh/Fish history */ + if (mc_global.shell->type == SHELL_ZSH || mc_global.shell->type == SHELL_FISH) { /* Per Zsh documentation last command prefixed with space lingers in the internal history * until the next command is entered before it vanishes. To make it vanish right away, - * type a space and press return. */ + * type a space and press return. + * + * Fish shell now also provides the same behavior: + * https://github.com/fish-shell/fish-shell/commit/9fdc4f903b8b421b18389a0f290d72cc88c128bb + * */ write_all (mc_global.tty.subshell_pty, " \n", 2); subshell_state = RUNNING_COMMAND; feed_subshell (QUIETLY, TRUE);