diff options
author | 2009-08-08 21:52:43 +0000 | |
---|---|---|
committer | 2009-08-08 21:52:43 +0000 | |
commit | 6f7d62ebc9d2569213457966b9dab344dd30c124 (patch) | |
tree | db1575bc7a8f723d64cf32fa11b69f42b628e4dd /usr.bin/tmux/tmux.c | |
parent | Tidy function a little by using a temporary variable. (diff) | |
download | wireguard-openbsd-6f7d62ebc9d2569213457966b9dab344dd30c124.tar.xz wireguard-openbsd-6f7d62ebc9d2569213457966b9dab344dd30c124.zip |
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 'usr.bin/tmux/tmux.c')
-rw-r--r-- | usr.bin/tmux/tmux.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c index 6959b4662f0..1beb777d275 100644 --- a/usr.bin/tmux/tmux.c +++ b/usr.bin/tmux/tmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.c,v 1.28 2009/08/08 20:36:42 nicm Exp $ */ +/* $OpenBSD: tmux.c,v 1.29 2009/08/08 21:52:43 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -44,6 +44,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; @@ -262,7 +263,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; @@ -320,6 +321,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 @@ -376,6 +381,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); @@ -469,10 +475,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); } |