diff options
author | Tiago Cunha <tcunha@gmx.com> | 2009-08-09 17:48:55 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2009-08-09 17:48:55 +0000 |
commit | 29b1b2fb5eee4319cdc1464ee377b68f3171dc27 (patch) | |
tree | 724627190ad66e119ec2771c5731e720a70ea3e9 /cmd-new-session.c | |
parent | af3db9a4fea9c436ff8e6f452a538ba295e1e6fe (diff) |
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.
Diffstat (limited to 'cmd-new-session.c')
-rw-r--r-- | cmd-new-session.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/cmd-new-session.c b/cmd-new-session.c index 21c7902a..181d9bb8 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-new-session.c,v 1.50 2009-08-09 15:26:24 tcunha Exp $ */ +/* $Id: cmd-new-session.c,v 1.51 2009-08-09 17:48:55 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -40,7 +40,7 @@ struct cmd_new_session_data { const struct cmd_entry cmd_new_session_entry = { "new-session", "new", "[-d] [-n window-name] [-s session-name] [command]", - CMD_STARTSERVER|CMD_CANTNEST, 0, + CMD_STARTSERVER|CMD_CANTNEST|CMD_SENDENVIRON, 0, cmd_new_session_init, cmd_new_session_parse, cmd_new_session_exec, @@ -108,6 +108,8 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) { struct cmd_new_session_data *data = self->data; struct session *s; + struct environ env; + const char *update; char *overrides, *cmd, *cwd, *cause; int detached; u_int sx, sy; @@ -184,13 +186,20 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) else cmd = options_get_string(&global_s_options, "default-command"); + /* Construct the environment. */ + environ_init(&env); + update = options_get_string(&global_s_options, "update-environment"); + if (ctx->cmdclient != NULL) + environ_update(update, &ctx->cmdclient->environ, &env); + /* Create the new session. */ - s = session_create(data->newname, cmd, cwd, sx, sy, &cause); + s = session_create(data->newname, cmd, cwd, &env, sx, sy, &cause); if (s == NULL) { ctx->error(ctx, "create session failed: %s", cause); xfree(cause); return (-1); } + environ_free(&env); if (data->winname != NULL) { xfree(s->curw->window->name); |