From 1e20153b6e90e6bfd4643667dad3d9971636ef6b Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 20 Feb 2013 09:32:52 +0000 Subject: [PATCH] Fix so capture-pane/save-buffer can work in control clients, from George Nachman. --- cmd-capture-pane.c | 5 ++++- cmd-save-buffer.c | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c index 80be0165..83ec303c 100644 --- a/cmd-capture-pane.c +++ b/cmd-capture-pane.c @@ -44,7 +44,7 @@ enum cmd_retval cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx) { struct args *args = self->args; - struct client *c = ctx->cmdclient; + struct client *c; struct window_pane *wp; char *buf, *line, *cause; struct screen *s; @@ -106,6 +106,9 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx) } if (args_has(args, 'p')) { + c = ctx->curclient; + if (c == NULL || !(c->flags & CLIENT_CONTROL)) + c = ctx->cmdclient; if (c == NULL) { ctx->error(ctx, "can't write to stdout"); return (CMD_RETURN_ERROR); diff --git a/cmd-save-buffer.c b/cmd-save-buffer.c index 638c5742..1d39bc9e 100644 --- a/cmd-save-buffer.c +++ b/cmd-save-buffer.c @@ -45,7 +45,7 @@ enum cmd_retval cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) { struct args *args = self->args; - struct client *c = ctx->cmdclient; + struct client *c; struct session *s; struct paste_buffer *pb; const char *path, *newpath, *wd; @@ -76,13 +76,17 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) path = args->argv[0]; if (strcmp(path, "-") == 0) { + c = ctx->curclient; + if (c == NULL || !(c->flags & CLIENT_CONTROL)) + c = ctx->cmdclient; if (c == NULL) { - ctx->error(ctx, "%s: can't write to stdout", path); + ctx->error(ctx, "can't write to stdout"); return (CMD_RETURN_ERROR); } evbuffer_add(c->stdout_data, pb->data, pb->size); server_push_stdout(c); } else { + c = ctx->cmdclient; if (c != NULL) wd = c->cwd; else if ((s = cmd_current_session(ctx, 0)) != NULL) {