diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-09-01 14:40:34 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-09-01 14:40:34 +0000 |
commit | 6fb41a10765db0e3b0ba0a163a759cb2564bde33 (patch) | |
tree | 748643775fc4f31816616ce1129962827e5452d5 | |
parent | 5e91709797605a03d07c1f29f92fdca4f00dbff6 (diff) |
If forking a login shell or if SHELL is otherwise not useful, set it to the
default shell. Based on a diff from martynas@.
-rw-r--r-- | usr.bin/tmux/window.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c index 8b05d63eba1..71dd36521f1 100644 --- a/usr.bin/tmux/window.c +++ b/usr.bin/tmux/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.23 2009/09/01 13:09:50 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.24 2009/09/01 14:40:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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"); } |