=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-save-buffer.c,v retrieving revision 1.16 retrieving revision 1.17 diff -c -r1.16 -r1.17 *** src/usr.bin/tmux/cmd-save-buffer.c 2012/07/11 07:10:15 1.16 --- src/usr.bin/tmux/cmd-save-buffer.c 2013/03/22 15:53:24 1.17 *************** *** 1,4 **** ! /* $OpenBSD: cmd-save-buffer.c,v 1.16 2012/07/11 07:10:15 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha --- 1,4 ---- ! /* $OpenBSD: cmd-save-buffer.c,v 1.17 2013/03/22 15:53:24 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha *************** *** 45,51 **** cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) { struct args *args = self->args; ! struct client *c = ctx->cmdclient; struct session *s; struct paste_buffer *pb; const char *path, *newpath, *wd; --- 45,51 ---- cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) { struct args *args = self->args; ! struct client *c; struct session *s; struct paste_buffer *pb; const char *path, *newpath, *wd; *************** *** 76,88 **** path = args->argv[0]; if (strcmp(path, "-") == 0) { if (c == NULL) { ! ctx->error(ctx, "%s: can't write to stdout", path); return (CMD_RETURN_ERROR); } evbuffer_add(c->stdout_data, pb->data, pb->size); server_push_stdout(c); } else { if (c != NULL) wd = c->cwd; else if ((s = cmd_current_session(ctx, 0)) != NULL) { --- 76,92 ---- 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, "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) {