summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/tmux.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/tmux/tmux.c')
-rw-r--r--usr.bin/tmux/tmux.c9
1 files changed, 5 insertions, 4 deletions
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);