From 29b1b2fb5eee4319cdc1464ee377b68f3171dc27 Mon Sep 17 00:00:00 2001 From: Tiago Cunha Date: Sun, 9 Aug 2009 17:48:55 +0000 Subject: Sync OpenBSD patchset 231: 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 session 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. --- cmd-split-window.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'cmd-split-window.c') diff --git a/cmd-split-window.c b/cmd-split-window.c index 253c95e7..07b1f56d 100644 --- a/cmd-split-window.c +++ b/cmd-split-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-split-window.c,v 1.21 2009-07-28 22:12:16 tcunha Exp $ */ +/* $Id: cmd-split-window.c,v 1.22 2009-08-09 17:48:55 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -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); -- cgit