Skip to content

Commit

Permalink
Merge branch '4521_fish_history'
Browse files Browse the repository at this point in the history
* 4521_fish_history:
  Ticket #4521: really escape fish shell history.
  • Loading branch information
aborodin committed Feb 11, 2024
2 parents a58e0a1 + ae45534 commit dc1aa3e
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/subshell/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit dc1aa3e

Please sign in to comment.