Skip to content

Commit 68da2b7

Browse files
committed
BUG: Filespecs are not properly quoted
Filespec(s, on individual lines) need to be shell-quoted, as they are passed (through xargs) to the opener. For the editor (which cannot simply be launched but needs to use the actual terminal so that the editor will be launched inside and therefore visible inside the pane), it's even worse: The concluding CR is only appended once, not for each file. Files should not be edited separately, anyway, but passed as multiple argments to a single editor instance. Also, the editor call itself should disable name lookup (send-keys -l) so that filenames that resemble a Tmux key aren't accidentally translated into a keypress. Inspired by tmux-plugins#38 (which provides a bad solution, though).
1 parent 82890bf commit 68da2b7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

open.tmux

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ is_cygwin() {
3030

3131
command_generator() {
3232
local command_string="$1"
33-
echo "{ cd \"\$(tmux display-message -p '#{pane_current_path}')\" && xargs -I {} $command_string \"{}\" >/dev/null; }"
33+
echo "{ cd \"\$(tmux display-message -p '#{pane_current_path}')\" && xargs -I {} printf '%q\\n' {} | xargs -I {} $command_string {} >/dev/null; }"
3434
}
3535

3636
search_command_generator() {
@@ -81,7 +81,7 @@ generate_editor_command() {
8181
editor=$(get_tmux_option "$open_editor_override" "$environment_editor")
8282
# vim freezes terminal unless there's the '--' argument. Other editors seem
8383
# to be fine with it (textmate [mate], light table [table]).
84-
echo "xargs -I {} tmux send-keys '$editor -- \"{}\"'; tmux send-keys 'C-m'"
84+
echo "xargs -I {} printf '%q\\n' {} | tmux send-keys -l \"$editor -- \$(tr '\\n' ' ')\"; tmux send-keys 'C-m'"
8585
}
8686

8787
set_copy_mode_open_bindings() {

0 commit comments

Comments
 (0)