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.
This commit is contained in:
Tiago Cunha
2009-08-09 17:48:55 +00:00
parent af3db9a4fe
commit 29b1b2fb5e
18 changed files with 562 additions and 77 deletions

16
tmux.c
View File

@ -1,4 +1,4 @@
/* $Id: tmux.c,v 1.157 2009-08-09 17:40:17 tcunha Exp $ */
/* $Id: tmux.c,v 1.158 2009-08-09 17:48:55 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -49,6 +49,7 @@ volatile sig_atomic_t sigusr2;
char *cfg_file;
struct options global_s_options; /* session options */
struct options global_w_options; /* window options */
struct environ global_environ;
int server_locked;
u_int password_failures;
@ -271,7 +272,7 @@ main(int argc, char **argv)
struct hdr hdr;
struct passwd *pw;
struct msg_print_data printdata;
char *s, *path, *label, *home, *cause;
char *s, *path, *label, *home, *cause, **var;
char cwd[MAXPATHLEN];
void *buf;
size_t len;
@ -329,6 +330,10 @@ main(int argc, char **argv)
log_open_tty(debug_level);
siginit();
environ_init(&global_environ);
for (var = environ; *var != NULL; var++)
environ_put(&global_environ, *var);
if (!(flags & IDENTIFY_UTF8)) {
/*
* If the user has set whichever of LC_ALL, LC_CTYPE or LANG
@ -385,6 +390,7 @@ main(int argc, char **argv)
options_set_number(&global_s_options, "status-utf8", 0);
options_set_string(&global_s_options,
"terminal-overrides", "*88col*:colors=88,*256col*:colors=256");
options_set_string(&global_s_options, "update-environment", "DISPLAY");
options_set_number(&global_s_options, "visual-activity", 0);
options_set_number(&global_s_options, "visual-bell", 0);
options_set_number(&global_s_options, "visual-content", 0);
@ -478,10 +484,10 @@ main(int argc, char **argv)
}
cmdflags &= ~CMD_STARTSERVER;
TAILQ_FOREACH(cmd, cmdlist, qentry) {
if (cmd->entry->flags & CMD_STARTSERVER) {
if (cmd->entry->flags & CMD_STARTSERVER)
cmdflags |= CMD_STARTSERVER;
break;
}
if (cmd->entry->flags & CMD_SENDENVIRON)
cmdflags |= CMD_SENDENVIRON;
}
cmd_list_free(cmdlist);
}