summaryrefslogtreecommitdiffstats
path: root/cmd-split-window.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-08-08 21:52:43 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-08-08 21:52:43 +0000
commit6491274f60c175b89b02b6e4cd0c59b13717e2ec (patch)
tree615959fa3459ad20491f0fedcfcce5a2940d0186 /cmd-split-window.c
parente9856294408c76f374547d9e74d4292f1b0c1163 (diff)
Infrastructure and commands to manage the environment for processes started
within tmux. There is a global environment, copied from the external environment when the server is started and each sesssion has an (initially empty) session environment which overrides it. New commands set-environment and show-environment manipulate or display the environments. A new session option, update-environment, is a space-separated list of variables which are updated from the external environment into the session environment every time a new session is created - the default is DISPLAY.
Diffstat (limited to 'cmd-split-window.c')
-rw-r--r--cmd-split-window.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/cmd-split-window.c b/cmd-split-window.c
index b483cdd4..70004a14 100644
--- a/cmd-split-window.c
+++ b/cmd-split-window.c
@@ -149,7 +149,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
struct winlink *wl;
struct window *w;
struct window_pane *wp;
- const char **env;
+ struct environ env;
char *cmd, *cwd, *cause;
u_int hlimit;
int size;
@@ -159,7 +159,10 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1);
w = wl->window;
- env = server_fill_environ(s);
+ environ_init(&env);
+ environ_copy(&global_environ, &env);
+ environ_copy(&s->environ, &env);
+ server_fill_environ(s, &env);
cmd = data->cmd;
if (cmd == NULL)
@@ -181,7 +184,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
type = LAYOUT_LEFTRIGHT;
wp = window_add_pane(w, hlimit);
- if (window_pane_spawn(wp, cmd, cwd, env, &cause) != 0)
+ if (window_pane_spawn(wp, cmd, cwd, &env, &cause) != 0)
goto error;
if (layout_split_pane(w->active, type, size, wp) != 0) {
cause = xstrdup("pane too small");
@@ -197,9 +200,11 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
} else
server_status_session(s);
+ environ_free(&env);
return (0);
error:
+ environ_free(&env);
if (wp != NULL)
window_remove_pane(w, wp);
ctx->error(ctx, "create pane failed: %s", cause);