aboutsummaryrefslogtreecommitdiff
path: root/window.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2012-05-30 13:47:33 +0000
committerTiago Cunha <tcunha@gmx.com>2012-05-30 13:47:33 +0000
commit2e3a2603156d94c2e40b401a3dfdd2ccc3d3bfbf (patch)
tree0e65729530d1752fb2b7fd42fae68b3e32034131 /window.c
parentb24829a99c0b106d2bf64446c12190e29a011fb4 (diff)
downloadrtmux-2e3a2603156d94c2e40b401a3dfdd2ccc3d3bfbf.tar.gz
rtmux-2e3a2603156d94c2e40b401a3dfdd2ccc3d3bfbf.tar.bz2
rtmux-2e3a2603156d94c2e40b401a3dfdd2ccc3d3bfbf.zip
Sync OpenBSD patchset 1127:
Use default-shell not _PATH_BSHELL to spawn commands, pointed out by Dennis G?nnewig and Thomas Adam.
Diffstat (limited to 'window.c')
-rw-r--r--window.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/window.c b/window.c
index fac56dc6..8eb11f20 100644
--- a/window.c
+++ b/window.c
@@ -740,23 +740,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");
}