diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2018-01-01 11:19:09 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2018-01-01 11:19:09 +0000 |
commit | 701f29719c86856421ae02770e7504e12d2f5749 (patch) | |
tree | 4523dc46184cb01536c03ec45ee317f5ea29e107 /usr.bin/tmux | |
parent | f9a986a5387b3f3edeca90c0077c4771a146f335 (diff) |
Prefer PWD for current directory if present in client, from Wei Zhao in
GitHub issue 1183.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/client.c | 10 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.c | 9 |
2 files changed, 10 insertions, 9 deletions
diff --git a/usr.bin/tmux/client.c b/usr.bin/tmux/client.c index bba7cfdc4ec..f3b2ed31d1c 100644 --- a/usr.bin/tmux/client.c +++ b/usr.bin/tmux/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.125 2017/12/19 15:00:39 nicm Exp $ */ +/* $OpenBSD: client.c,v 1.126 2018/01/01 11:19:08 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -279,10 +279,10 @@ client_main(struct event_base *base, int argc, char **argv, int flags) client_peer = proc_add_peer(client_proc, fd, client_dispatch, NULL); /* Save these before pledge(). */ - if ((cwd = getcwd(path, sizeof path)) == NULL) { - if ((cwd = find_home()) == NULL) - cwd = "/"; - } + if ((cwd = getenv("PWD")) == NULL && + (cwd = getcwd(path, sizeof path)) == NULL && + (cwd = find_home()) == NULL) + cwd = "/"; if ((ttynam = ttyname(STDIN_FILENO)) == NULL) ttynam = ""; diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c index c3a01d0aa53..4f9718ec285 100644 --- a/usr.bin/tmux/tmux.c +++ b/usr.bin/tmux/tmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.c,v 1.184 2017/07/12 09:21:25 nicm Exp $ */ +/* $OpenBSD: tmux.c,v 1.185 2018/01/01 11:19:08 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -193,7 +193,7 @@ main(int argc, char **argv) { char *path, *label, **var; char tmp[PATH_MAX]; - const char *s, *shell; + const char *s, *shell, *cwd; int opt, flags, keys; const struct options_table_entry *oe; @@ -294,8 +294,9 @@ main(int argc, char **argv) global_environ = environ_create(); for (var = environ; *var != NULL; var++) environ_put(global_environ, *var); - if (getcwd(tmp, sizeof tmp) != NULL) - environ_set(global_environ, "PWD", "%s", tmp); + if ((cwd = getenv("PWD")) == NULL && + (cwd = getcwd(tmp, sizeof tmp)) != NULL) + environ_set(global_environ, "PWD", "%s", cwd); global_options = options_create(NULL); global_s_options = options_create(NULL); |