summaryrefslogtreecommitdiffstats
path: root/cmd-capture-pane.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd-capture-pane.c')
-rw-r--r--cmd-capture-pane.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c
index 588b0fd5..6f37bc8f 100644
--- a/cmd-capture-pane.c
+++ b/cmd-capture-pane.c
@@ -214,15 +214,20 @@ cmd_capture_pane_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_ERROR);
if (args_has(args, 'p')) {
- if (!file_can_print(c)) {
- cmdq_error(item, "can't write output to client");
+ if (len > 0 && buf[len - 1] == '\n')
+ len--;
+ if (c->flags & CLIENT_CONTROL)
+ control_write(c, "%.*s", (int)len, buf);
+ else {
+ if (!file_can_print(c)) {
+ cmdq_error(item, "can't write to client");
+ free(buf);
+ return (CMD_RETURN_ERROR);
+ }
+ file_print_buffer(c, buf, len);
+ file_print(c, "\n");
free(buf);
- return (CMD_RETURN_ERROR);
}
- file_print_buffer(c, buf, len);
- if (args_has(args, 'P') && len > 0)
- file_print(c, "\n");
- free(buf);
} else {
bufname = NULL;
if (args_has(args, 'b'))