From 7447bd9c9c8021bd0cac1128297bb056643d2480 Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Date: Thu, 8 Oct 2020 17:29:33 +0200
Subject: [PATCH 4/7] prevent word-splitting of the subshell command buffer
this avoids inadvertent whitespace normalization (compression and
trimming), which is annoying and additionally invalidates the cursor
position.
for bash and zsh that meant quoting the variable expansion, while for
fish it meant removing the pointless indirection through echo.
for bash we had to introduce an indirection through a function, as there
is apparently no way to get the quoting right inside the binding. zsh
already had such an indirection - maybe for the same reason?
amends ff0fc17a.
---
src/subshell/common.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/subshell/common.c b/src/subshell/common.c
index 3e1a2f7ee..f9f6aca4e 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 | | " bind -x '\"\\e" SHELL_BUFFER_KEYBINDING "\":\"echo $READLINE_LINE>&%d\"'\n" |
| 1057 | " mc_print_command_buffer () { echo \"$READLINE_LINE\" >&%d; }\n" |
| 1058 | " bind -x '\"\\e" SHELL_BUFFER_KEYBINDING "\":\"mc_print_command_buffer\"'\n" |
1058 | 1059 | " bind -x '\"\\e" SHELL_CURSOR_KEYBINDING "\":\"echo $READLINE_POINT>&%d\"'\n" |
1059 | 1060 | " PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND\n}'pwd>&%d;kill -STOP $$'\n" |
1060 | 1061 | "PS1='\\u@\\h:\\w\\$ '\n", |
… |
… |
init_subshell_precmd (char *precmd, size_t buff_size) |
1117 | 1118 | |
1118 | 1119 | case SHELL_ZSH: |
1119 | 1120 | g_snprintf (precmd, buff_size, |
1120 | | " mc_print_command_buffer () { echo $BUFFER >&%d}\n" |
| 1121 | " mc_print_command_buffer () { echo \"$BUFFER\"' >&%d}\n" |
1121 | 1122 | " zle -N mc_print_command_buffer\n" |
1122 | 1123 | " bindkey '^[" SHELL_BUFFER_KEYBINDING "' mc_print_command_buffer\n" |
1123 | 1124 | " mc_print_cursor_position () { echo $CURSOR >&%d}\n" |
… |
… |
init_subshell_precmd (char *precmd, size_t buff_size) |
1136 | 1137 | break; |
1137 | 1138 | case SHELL_FISH: |
1138 | 1139 | g_snprintf (precmd, buff_size, |
1139 | | " bind \\e" SHELL_BUFFER_KEYBINDING " 'echo (commandline)>&%d';" |
1140 | | "bind \\e" SHELL_CURSOR_KEYBINDING " 'echo (commandline -C)>&%d';" |
| 1140 | " bind \\e" SHELL_BUFFER_KEYBINDING " 'commandline >&%d';" |
| 1141 | "bind \\e" SHELL_CURSOR_KEYBINDING " 'commandline -C >&%d';" |
1141 | 1142 | "if not functions -q fish_prompt_mc;" |
1142 | 1143 | "functions -e fish_right_prompt;" |
1143 | 1144 | "functions -c fish_prompt fish_prompt_mc; end;" |