Ticket #4126: 0005-make-query-of-subshell-command-buffer-leading-dash-s.patch

File 0005-make-query-of-subshell-command-buffer-leading-dash-s.patch, 1.8 KB (added by ossi, 4 years ago)
  • src/subshell/common.c

    From b5b62c1c5d8cecdd590212926d26fcaca3a5cf8b Mon Sep 17 00:00:00 2001
    From: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
    Date: Thu, 8 Oct 2020 14:21:33 +0200
    Subject: [PATCH 5/7] make query of subshell command buffer leading-dash-safe
    
    when the command buffer started with a valid option to the "echo"
    command, weird things would happen. use "printf" instead, which doesn't
    have this problem. this affected only the bash and zsh code paths.
    
    amends ff0fc17a.
    ---
     src/subshell/common.c | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/src/subshell/common.c b/src/subshell/common.c
    index f9f6aca4e..32577bcb2 100644
    a b init_subshell_precmd (char *precmd, size_t buff_size) 
    10541054    { 
    10551055    case SHELL_BASH: 
    10561056        g_snprintf (precmd, buff_size, 
    1057                     " mc_print_command_buffer () { echo \"$READLINE_LINE\" >&%d; }\n" 
     1057                    " mc_print_command_buffer () { printf \"%%s\\\\n\" \"$READLINE_LINE\" >&%d; }\n" 
    10581058                    " bind -x '\"\\e" SHELL_BUFFER_KEYBINDING "\":\"mc_print_command_buffer\"'\n" 
    10591059                    " bind -x '\"\\e" SHELL_CURSOR_KEYBINDING "\":\"echo $READLINE_POINT>&%d\"'\n" 
    10601060                    " PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND\n}'pwd>&%d;kill -STOP $$'\n" 
    init_subshell_precmd (char *precmd, size_t buff_size) 
    11181118 
    11191119    case SHELL_ZSH: 
    11201120        g_snprintf (precmd, buff_size, 
    1121                     " mc_print_command_buffer () { echo \"$BUFFER\"' >&%d}\n" 
     1121                    " mc_print_command_buffer () { printf \"%%s\\\\n\" \"$BUFFER\" >&%d; }\n" 
    11221122                    " zle -N mc_print_command_buffer\n" 
    11231123                    " bindkey '^[" SHELL_BUFFER_KEYBINDING "' mc_print_command_buffer\n" 
    11241124                    " mc_print_cursor_position () { echo $CURSOR >&%d}\n"