diff options
author | 2020-07-21 05:24:33 +0000 | |
---|---|---|
committer | 2020-07-21 05:24:33 +0000 | |
commit | 6523adaf40d6372ad01dfc58080ef33d68b70165 (patch) | |
tree | 6e5d1bc59cead35acc038e005ab2c539b4dc5002 /usr.bin/tmux/cmd-save-buffer.c | |
parent | extra garbage line found during archeology (diff) | |
download | wireguard-openbsd-6523adaf40d6372ad01dfc58080ef33d68b70165.tar.xz wireguard-openbsd-6523adaf40d6372ad01dfc58080ef33d68b70165.zip |
Fix show-buffer when run from inside tmux, GitHub issue 2314.
Diffstat (limited to 'usr.bin/tmux/cmd-save-buffer.c')
-rw-r--r-- | usr.bin/tmux/cmd-save-buffer.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/usr.bin/tmux/cmd-save-buffer.c b/usr.bin/tmux/cmd-save-buffer.c index 1a31ad951e0..cb968126bad 100644 --- a/usr.bin/tmux/cmd-save-buffer.c +++ b/usr.bin/tmux/cmd-save-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-save-buffer.c,v 1.50 2020/04/13 20:51:57 nicm Exp $ */ +/* $OpenBSD: cmd-save-buffer.c,v 1.51 2020/07/21 05:24:33 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -74,11 +74,12 @@ static enum cmd_retval cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = cmd_get_args(self); + struct client *c = cmdq_get_client(item); struct paste_buffer *pb; int flags; const char *bufname = args_get(args, 'b'), *bufdata; size_t bufsize; - char *path; + char *path, *tmp; if (bufname == NULL) { if ((pb = paste_get_top(NULL)) == NULL) { @@ -94,9 +95,16 @@ cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item) } bufdata = paste_buffer_data(pb, &bufsize); - if (cmd_get_entry(self) == &cmd_show_buffer_entry) + if (cmd_get_entry(self) == &cmd_show_buffer_entry) { + if (c->session != NULL || (c->flags & CLIENT_CONTROL)) { + utf8_stravisx(&tmp, bufdata, bufsize, + VIS_OCTAL|VIS_CSTYLE|VIS_TAB); + cmdq_print(item, "%s", tmp); + free(tmp); + return (CMD_RETURN_NORMAL); + } path = xstrdup("-"); - else + } else path = format_single_from_target(item, args->argv[0]); if (args_has(args, 'a')) flags = O_APPEND; |