Merge branch '4521_fish_history'

* 4521_fish_history:
  Ticket #4521: really escape fish shell history.
This commit is contained in:
Andrew Borodin 2024-02-11 19:20:55 +03:00
commit dc1aa3e4e3
1 changed files with 19 additions and 3 deletions

View File

@ -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);