aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2012-05-28 08:55:43 +0000
committerNicholas Marriott <nicm@openbsd.org>2012-05-28 08:55:43 +0000
commitf51c55c3f032e4c525cc7aa7ac74c1ce4a9d29ab (patch)
treec0e275c09d1c066a4a4f4da919677148408282e8
parentfbf2bd865cb2ea19572a259f2011f37975e41647 (diff)
downloadrtmux-f51c55c3f032e4c525cc7aa7ac74c1ce4a9d29ab.tar.gz
rtmux-f51c55c3f032e4c525cc7aa7ac74c1ce4a9d29ab.tar.bz2
rtmux-f51c55c3f032e4c525cc7aa7ac74c1ce4a9d29ab.zip
Use default-shell not _PATH_BSHELL to spawn commands, pointed out by
Dennis G?nnewig and Thomas Adam.
-rw-r--r--window.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/window.c b/window.c
index 9071972d..0d2b74bf 100644
--- a/window.c
+++ b/window.c
@@ -739,23 +739,24 @@ window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell,
clear_signals(1);
log_close();
- if (*wp->cmd != '\0') {
- /* Set SHELL but only if it is currently not useful. */
- shell = getenv("SHELL");
- if (checkshell(shell))
- setenv("SHELL", wp->shell, 1);
+ setenv("SHELL", wp->shell, 1);
+ ptr = strrchr(wp->shell, '/');
- execl(_PATH_BSHELL, "sh", "-c", wp->cmd, (char *) NULL);
+ if (*wp->cmd != '\0') {
+ /* Use the command. */
+ if (ptr != NULL && *(ptr + 1) != '\0')
+ xasprintf(&argv0, "%s", ptr + 1);
+ else
+ xasprintf(&argv0, "%s", wp->shell);
+ execl(wp->shell, argv0, "-c", wp->cmd, (char *) NULL);
fatal("execl failed");
}
/* No command; fork a login shell. */
- ptr = strrchr(wp->shell, '/');
if (ptr != NULL && *(ptr + 1) != '\0')
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");
}