Fix bug where trailing semicolon at end of line would be omitted

Tmux assumes a semicolon at the end of a command-line argument means
that a new command is started. See tmux man page around "Multiple
commands may ... a command sequence." This allows, for example, the
following two commands to be executed in one line:

    tmux new-window; split-window -d

Unfortunately, this behaviour meant that trailing semicolons would not
be sent from ob-tmux. For instance,

echo hello;

would yield

> echo hello

In bash, a semi-colon is also interpreted as a command
separator. Hence, zapping the semicolon would usually not cause any
problems. It does, however, cause problems in multi-line strings,
heredocs, etc.

In short, the bug has now been fixed. I have checked that tmux does
not eat any other characters. The code that removes the semicolon is
in the function cmd_list_parse in the file cmd-list.c in the tmux
source code.
pull/8/head
Allard Hendriksen 2018-08-31 12:17:45 +02:00
parent 4b5c30eea9
commit 73bed0ebad
1 changed files with 18 additions and 1 deletions

View File

@ -255,7 +255,24 @@ Argument OB-SESSION: the current ob-tmux session."
"send-keys"
"-l"
"-t" (ob-tmux--target ob-session)
line "\n")))
;; Replace semicolon at end of line with `\;'.
;; Tmux assumes a semicolon at the end of a command-line argument
;; means that a new command is started. See tmux man page around
;; "Multiple commands may ... a command sequence." This allows,
;; for example, the following two commands to be executed in one
;; line:
;;
;; tmux new-window; split-window -d
;;
;; To prevent tmux from interpreting a trailing semicolon as a
;; command separator, we replace the semicolon with `\;'.
;;
;; Note: we are already using the `-l' (literal) flag. This does
;; not prevent tmux from interpreting a trailing semicolon as a
;; command separator.
(replace-regexp-in-string ";$" "\\\\;" line)
"\n")))
(defun ob-tmux--send-body (ob-session body)
"If tmux window (passed in OB-SESSION) exists, send BODY to it.