fix shell escaping issues in Tmux#set_buffer

This commit is contained in:
Jorge Morante 2023-08-13 11:59:05 +02:00
parent 77b41be413
commit 9292a4a830
1 changed files with 15 additions and 1 deletions

View File

@ -197,7 +197,21 @@ class Tmux
def set_buffer(value)
return unless value
exec(["set-buffer", value].join(' '))
# To avoid shell escaping nightmares, we'll use Process and write directly to stdin
cmd = Process.new(
tmux,
["load-buffer", "-w", "-"],
input: :pipe,
output: :pipe,
error: :pipe,
)
cmd.input.print(value)
cmd.input.flush
cmd.close
nil
end
def select_pane(id)