mirror of
https://github.com/tmux/tmux.git
synced 2025-09-01 20:57:00 +00:00
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.
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user