diff options
author | nicm <nicm> | 2017-11-09 23:02:13 +0000 |
---|---|---|
committer | nicm <nicm> | 2017-11-09 23:02:13 +0000 |
commit | 384736e9550be328e0209c1f217b164d2fbc8fa1 (patch) | |
tree | 2250daf7287da01f479124381f2466e507da2131 /window.c | |
parent | a2681ffcee99a83d33d159132bb8e748f4144dd3 (diff) | |
download | rtmux-384736e9550be328e0209c1f217b164d2fbc8fa1.tar.gz rtmux-384736e9550be328e0209c1f217b164d2fbc8fa1.tar.bz2 rtmux-384736e9550be328e0209c1f217b164d2fbc8fa1.zip |
If we successfully change the directory, set PWD too to give the shell a
hint in case of symlinks.
Diffstat (limited to 'window.c')
-rw-r--r-- | window.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -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); |