=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-save-buffer.c,v retrieving revision 1.11 retrieving revision 1.12 diff -c -r1.11 -r1.12 *** src/usr.bin/tmux/cmd-save-buffer.c 2011/10/23 00:49:25 1.11 --- src/usr.bin/tmux/cmd-save-buffer.c 2011/10/23 08:34:01 1.12 *************** *** 1,4 **** ! /* $OpenBSD: cmd-save-buffer.c,v 1.11 2011/10/23 00:49:25 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha --- 1,4 ---- ! /* $OpenBSD: cmd-save-buffer.c,v 1.12 2011/10/23 08:34:01 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha *************** *** 45,52 **** { struct args *args = self->args; struct client *c = ctx->cmdclient; struct paste_buffer *pb; ! const char *path; char *cause; int buffer; mode_t mask; --- 45,53 ---- { struct args *args = self->args; struct client *c = ctx->cmdclient; + struct session *s; struct paste_buffer *pb; ! const char *path, *newpath, *wd; char *cause; int buffer; mode_t mask; *************** *** 80,85 **** --- 81,100 ---- } bufferevent_write(c->stdout_event, pb->data, pb->size); } else { + if (c != NULL) + wd = c->cwd; + else if ((s = cmd_current_session(ctx, 0)) != NULL) { + wd = options_get_string(&s->options, "default-path"); + if (*wd == '\0') + wd = s->cwd; + } else + wd = NULL; + if (wd != NULL && *wd != '\0') { + newpath = get_full_path(wd, path); + if (newpath != NULL) + path = newpath; + } + mask = umask(S_IRWXG | S_IRWXO); if (args_has(self->args, 'a')) f = fopen(path, "ab");