Ticket #4521: fish_cd_history_v2.patch

File fish_cd_history_v2.patch, 1.9 KB (added by htower, 4 months ago)
  • src/subshell/common.c

    diff --git a/src/subshell/common.c b/src/subshell/common.c
    index 1c432fd7e..f6f638811 100644
    a b do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt) 
    17141714                return; 
    17151715            } 
    17161716    } 
     1717 
     1718    // A quick and dirty fix for fish shell. For some reason, fish does not  
     1719    // execute all the commands sent to it from Midnight Commander :( 
     1720    // An example of such buggy behavior is presented in ticket #4521. 
     1721    // TODO: Find the real cause and fix it "the right way" 
     1722    if (mc_global.shell->type == SHELL_FISH) 
     1723    { 
     1724        write_all (mc_global.tty.subshell_pty, "\n", 1); 
     1725        subshell_state = RUNNING_COMMAND; 
     1726        feed_subshell (QUIETLY, TRUE); 
     1727    } 
     1728 
    17171729    /* The initial space keeps this out of the command history (in bash 
    17181730       because we set "HISTCONTROL=ignorespace") */ 
    17191731    write_all (mc_global.tty.subshell_pty, " cd ", 4); 
    do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt) 
    17781790        } 
    17791791    } 
    17801792 
    1781     /* Really escape Zsh history */ 
    1782     if (mc_global.shell->type == SHELL_ZSH) 
     1793    /* Really escape Zsh/Fish history */ 
     1794    if (mc_global.shell->type == SHELL_ZSH || mc_global.shell->type == SHELL_FISH) 
    17831795    { 
    17841796        /* Per Zsh documentation last command prefixed with space lingers in the internal history 
    17851797         * until the next command is entered before it vanishes. To make it vanish right away, 
    1786          * type a space and press return. */ 
     1798         * type a space and press return. 
     1799         * 
     1800         * Fish shell now also provides the same behavior: 
     1801         * https://github.com/fish-shell/fish-shell/commit/9fdc4f903b8b421b18389a0f290d72cc88c128bb 
     1802         * */ 
    17871803        write_all (mc_global.tty.subshell_pty, " \n", 2); 
    17881804        subshell_state = RUNNING_COMMAND; 
    17891805        feed_subshell (QUIETLY, TRUE);