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) |
1054 | 1054 | { |
1055 | 1055 | case SHELL_BASH: |
1056 | 1056 | 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" |
1058 | 1058 | " bind -x '\"\\e" SHELL_BUFFER_KEYBINDING "\":\"mc_print_command_buffer\"'\n" |
1059 | 1059 | " bind -x '\"\\e" SHELL_CURSOR_KEYBINDING "\":\"echo $READLINE_POINT>&%d\"'\n" |
1060 | 1060 | " PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND\n}'pwd>&%d;kill -STOP $$'\n" |
… |
… |
init_subshell_precmd (char *precmd, size_t buff_size) |
1118 | 1118 | |
1119 | 1119 | case SHELL_ZSH: |
1120 | 1120 | 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" |
1122 | 1122 | " zle -N mc_print_command_buffer\n" |
1123 | 1123 | " bindkey '^[" SHELL_BUFFER_KEYBINDING "' mc_print_command_buffer\n" |
1124 | 1124 | " mc_print_cursor_position () { echo $CURSOR >&%d}\n" |