From c089e19020a55d5df5887821dda30cb8281dcc75 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Tue, 1 Sep 2009 14:40:33 +0000 Subject: [PATCH] If forking a login shell or if SHELL is otherwise not useful, set it to the default shell. Based on a diff from martynas@. --- window.c | 6 ++++++ 1 file changed, 6 insertions(+) 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"); }