summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-split-window.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/tmux/cmd-split-window.c')
-rw-r--r--usr.bin/tmux/cmd-split-window.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/usr.bin/tmux/cmd-split-window.c b/usr.bin/tmux/cmd-split-window.c
index cff67bdf0d5..fcf915742cc 100644
--- a/usr.bin/tmux/cmd-split-window.c
+++ b/usr.bin/tmux/cmd-split-window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-split-window.c,v 1.79 2017/03/08 13:36:12 nicm Exp $ */
+/* $OpenBSD: cmd-split-window.c,v 1.80 2017/03/09 17:02:38 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -71,11 +71,6 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
server_unzoom_window(w);
- env = environ_create();
- environ_copy(global_environ, env);
- environ_copy(s->environ, env);
- server_fill_environ(s, env);
-
if (args->argc == 0) {
cmd = options_get_string(s->options, "default-command");
if (cmd != NULL && *cmd != '\0') {
@@ -148,9 +143,13 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
if (envent != NULL)
path = envent->value;
+ env = environ_for_session(s);
if (window_pane_spawn(new_wp, argc, argv, path, shell, cwd, env,
- s->tio, &cause) != 0)
+ s->tio, &cause) != 0) {
+ environ_free(env);
goto error;
+ }
+ environ_free(env);
server_redraw_window(w);
@@ -161,8 +160,6 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
} else
server_status_session(s);
- environ_free(env);
-
if (args_has(args, 'P')) {
if ((template = args_get(args, 'F')) == NULL)
template = SPLIT_WINDOW_TEMPLATE;
@@ -186,7 +183,6 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_NORMAL);
error:
- environ_free(env);
if (new_wp != NULL) {
layout_close_pane(new_wp);
window_remove_pane(w, new_wp);