=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-load-buffer.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- src/usr.bin/tmux/cmd-load-buffer.c 2011/10/23 00:49:25 1.18 +++ src/usr.bin/tmux/cmd-load-buffer.c 2011/10/23 08:34:01 1.19 @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-load-buffer.c,v 1.18 2011/10/23 00:49:25 nicm Exp $ */ +/* $OpenBSD: cmd-load-buffer.c,v 1.19 2011/10/23 08:34:01 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha @@ -48,8 +48,9 @@ { struct args *args = self->args; struct client *c = ctx->cmdclient; + struct session *s; FILE *f; - const char *path; + const char *path, *newpath, *wd; char *pdata, *new_pdata, *cause; size_t psize; u_int limit; @@ -93,6 +94,19 @@ return (1); } + 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; + } if ((f = fopen(path, "rb")) == NULL) { ctx->error(ctx, "%s: %s", path, strerror(errno)); return (-1);