diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-11-09 23:02:14 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-11-09 23:02:14 +0000 |
commit | 05814ed3a653c1ae6364f1b6ea801e1b809aa292 (patch) | |
tree | 1c0ed46c61d56ec14542a1bd1ada63b8f6b43b2f | |
parent | 67a419b1b1146e6a39a1f7d97b7bf6647508f222 (diff) |
If we successfully change the directory, set PWD too to give the shell a
hint in case of symlinks.
-rw-r--r-- | usr.bin/tmux/window.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c index b5023cb98a2..46c63285e88 100644 --- a/usr.bin/tmux/window.c +++ b/usr.bin/tmux/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.206 2017/10/12 11:32:27 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.207 2017/11/09 23:02:13 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -935,10 +935,13 @@ window_pane_spawn(struct window_pane *wp, int argc, char **argv, proc_clear_signals(server_proc, 1); sigprocmask(SIG_SETMASK, &oldset, NULL); - if (chdir(wp->cwd) != 0) { - if ((home = find_home()) == NULL || chdir(home) != 0) - chdir("/"); - } + cwd = NULL; + if (chdir(wp->cwd) == 0) + cwd = wp->cwd; + else if ((home = find_home()) != NULL && chdir(home) == 0) + cwd = home; + else + chdir("/"); if (tcgetattr(STDIN_FILENO, &tio2) != 0) fatal("tcgetattr failed"); @@ -953,6 +956,8 @@ window_pane_spawn(struct window_pane *wp, int argc, char **argv, if (path != NULL) environ_set(env, "PATH", "%s", path); + if (cwd != NULL) + environ_set(env, "PWD", "%s", cwd); environ_set(env, "TMUX_PANE", "%%%u", wp->id); environ_push(env); |