summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/server-client.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2018-05-24 09:42:49 +0000
committernicm <nicm@openbsd.org>2018-05-24 09:42:49 +0000
commit8a00c84cfc00a28fa8b08e6f9e7c012de7ccc786 (patch)
tree12e36be4a7f7bf31f3e2d3675296183cf5d7e3c9 /usr.bin/tmux/server-client.c
parentImprove logging of the environment etc for new panes. (diff)
downloadwireguard-openbsd-8a00c84cfc00a28fa8b08e6f9e7c012de7ccc786.tar.xz
wireguard-openbsd-8a00c84cfc00a28fa8b08e6f9e7c012de7ccc786.zip
Make server_client_get_cwd used (almost) everywhere we need to work out
the cwd, and do not fall back to "." as it is pretty useless. GitHub issue 1331.
Diffstat (limited to 'usr.bin/tmux/server-client.c')
-rw-r--r--usr.bin/tmux/server-client.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index 2ff84e0ea4a..7c7da257448 100644
--- a/usr.bin/tmux/server-client.c
+++ b/usr.bin/tmux/server-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-client.c,v 1.249 2018/03/08 08:09:10 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.250 2018/05/24 09:42:49 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1847,15 +1847,19 @@ server_client_add_message(struct client *c, const char *fmt, ...)
/* Get client working directory. */
const char *
-server_client_get_cwd(struct client *c)
+server_client_get_cwd(struct client *c, struct session *s)
{
- struct session *s;
+ const char *home;
if (c != NULL && c->session == NULL && c->cwd != NULL)
return (c->cwd);
+ if (s != NULL && s->cwd != NULL)
+ return (s->cwd);
if (c != NULL && (s = c->session) != NULL && s->cwd != NULL)
return (s->cwd);
- return (".");
+ if ((home = find_home()) != NULL)
+ return (home);
+ return ("/");
}
/* Resolve an absolute path or relative to client working directory. */
@@ -1867,7 +1871,7 @@ server_client_get_path(struct client *c, const char *file)
if (*file == '/')
path = xstrdup(file);
else
- xasprintf(&path, "%s/%s", server_client_get_cwd(c), file);
+ xasprintf(&path, "%s/%s", server_client_get_cwd(c, NULL), file);
if (realpath(path, resolved) == NULL)
return (path);
free(path);