aboutsummaryrefslogtreecommitdiff
path: root/window.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-09-01 14:40:33 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-09-01 14:40:33 +0000
commitc089e19020a55d5df5887821dda30cb8281dcc75 (patch)
treea26172630578b4c6ef37c27dc08ebb442dc7d8ad /window.c
parent7d5e4947160d9355353c29a983e373b66c05abef (diff)
downloadrtmux-c089e19020a55d5df5887821dda30cb8281dcc75.tar.gz
rtmux-c089e19020a55d5df5887821dda30cb8281dcc75.tar.bz2
rtmux-c089e19020a55d5df5887821dda30cb8281dcc75.zip
If forking a login shell or if SHELL is otherwise not useful, set it to the
default shell. Based on a diff from martynas@.
Diffstat (limited to 'window.c')
-rw-r--r--window.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/window.c b/window.c
index 97381785..62b1f487 100644
--- a/window.c
+++ b/window.c
@@ -512,6 +512,11 @@ window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell,
log_close();
if (*wp->cmd != '\0') {
+ /* Set SHELL but only if it is currently not useful. */
+ shell = getenv("SHELL");
+ if (shell == NULL || *shell == '\0' || areshell(shell))
+ setenv("SHELL", wp->shell, 1);
+
execl(_PATH_BSHELL, "sh", "-c", wp->cmd, (char *) NULL);
fatal("execl failed");
}
@@ -522,6 +527,7 @@ window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell,
xasprintf(&argv0, "-%s", ptr + 1);
else
xasprintf(&argv0, "-%s", wp->shell);
+ setenv("SHELL", wp->shell, 1);
execl(wp->shell, argv0, (char *) NULL);
fatal("execl failed");
}