diff options
author | nicm <nicm> | 2019-12-12 11:39:56 +0000 |
---|---|---|
committer | nicm <nicm> | 2019-12-12 11:39:56 +0000 |
commit | c284ebe0ade7cc85ad6c3fe5ce7ed5108119222d (patch) | |
tree | 52fa29b04da1e5468bdce23cce61bf0370923c2e /cmd-capture-pane.c | |
parent | 64fb7e472a9e627ee486707ab9d30b607d76478a (diff) | |
download | rtmux-c284ebe0ade7cc85ad6c3fe5ce7ed5108119222d.tar.gz rtmux-c284ebe0ade7cc85ad6c3fe5ce7ed5108119222d.tar.bz2 rtmux-c284ebe0ade7cc85ad6c3fe5ce7ed5108119222d.zip |
Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to
how works for stdin, stdout, stderr. This makes special files like
/dev/fd/X work (used by some shells). stdin, stdout and stderr and
control mode are now just special cases of the same mechanism. This will
also make it easier to use for other commands that read files such as
source-file.
Diffstat (limited to 'cmd-capture-pane.c')
-rw-r--r-- | cmd-capture-pane.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c index fc6c26e4..18be3f77 100644 --- a/cmd-capture-pane.c +++ b/cmd-capture-pane.c @@ -193,7 +193,7 @@ static enum cmd_retval cmd_capture_pane_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = self->args; - struct client *c; + struct client *c = item->client; struct window_pane *wp = item->target.wp; char *buf, *cause; const char *bufname; @@ -214,18 +214,15 @@ cmd_capture_pane_exec(struct cmd *self, struct cmdq_item *item) return (CMD_RETURN_ERROR); if (args_has(args, 'p')) { - c = item->client; - if (c == NULL || - (c->session != NULL && !(c->flags & CLIENT_CONTROL))) { - cmdq_error(item, "can't write to stdout"); + if (!file_can_print(c)) { + cmdq_error(item, "can't write output to client"); free(buf); return (CMD_RETURN_ERROR); } - evbuffer_add(c->stdout_data, buf, len); - free(buf); + file_print_buffer(c, buf, len); if (args_has(args, 'P') && len > 0) - evbuffer_add(c->stdout_data, "\n", 1); - server_client_push_stdout(c); + file_print(c, "\n"); + free(buf); } else { bufname = NULL; if (args_has(args, 'b')) |