diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-10-10 12:26:38 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-10-10 12:26:38 +0000 |
commit | 45f3bf15f28f8351e44e2910c4c7c3652363e9de (patch) | |
tree | a80c083edb5c53cb8850a960930e1a9556680a32 /usr.bin/tmux/cmd-load-buffer.c | |
parent | 92c661700f1f33017b9137081f422afbfbcf1371 (diff) |
Alter how tmux handles the working directory to internally use file
descriptors rather than strings.
- Each session still has a current working directory.
- New sessions still get their working directory from the client that
created them or its attached session if any.
- New windows are created by default in the session working directory.
- The -c flag to new, neww, splitw allows the working directory to be
overridden.
- The -c flag to attach let's the session working directory be changed.
- The default-path option has been removed.
To get the equivalent to default-path '.', do:
bind c neww -c $PWD
To get the equivalent of default-path '~', do:
bind c neww -c ~
This also changes the client identify protocol to be a set of messages rather
than one as well as some other changes that should make it easier to make
backwards-compatible protocol changes in future.
Diffstat (limited to 'usr.bin/tmux/cmd-load-buffer.c')
-rw-r--r-- | usr.bin/tmux/cmd-load-buffer.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/usr.bin/tmux/cmd-load-buffer.c b/usr.bin/tmux/cmd-load-buffer.c index e46fa098dd2..1fa7583b119 100644 --- a/usr.bin/tmux/cmd-load-buffer.c +++ b/usr.bin/tmux/cmd-load-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-load-buffer.c,v 1.24 2013/10/10 12:00:21 nicm Exp $ */ +/* $OpenBSD: cmd-load-buffer.c,v 1.25 2013/10/10 12:26:35 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -19,6 +19,7 @@ #include <sys/types.h> #include <errno.h> +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -49,11 +50,11 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_q *cmdq) struct client *c = cmdq->client; struct session *s; FILE *f; - const char *path, *newpath, *wd; + const char *path; char *pdata, *new_pdata, *cause; size_t psize; u_int limit; - int ch, error, buffer, *buffer_ptr; + int ch, error, buffer, *buffer_ptr, cwd, fd; if (!args_has(args, 'b')) buffer = -1; @@ -81,20 +82,17 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_q *cmdq) return (CMD_RETURN_WAIT); } - if (c != NULL) - wd = c->cwd; - else if ((s = cmd_current_session(cmdq, 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) { + if (c != NULL && c->session == NULL) + cwd = c->cwd; + else if ((s = cmd_current_session(cmdq, 0)) != NULL) + cwd = s->cwd; + else + cwd = AT_FDCWD; + + if ((fd = openat(cwd, path, O_RDONLY)) == -1 || + (f = fdopen(fd, "rb")) == NULL) { + if (fd != -1) + close(fd); cmdq_error(cmdq, "%s: %s", path, strerror(errno)); return (CMD_RETURN_ERROR); } |