mirror of
https://github.com/tmux/tmux.git
synced 2025-09-01 20:57:00 +00:00
Move server_fill_environ into environ.c and move some other common code
into it.
This commit is contained in:
26
environ.c
26
environ.c
@ -20,6 +20,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
@ -218,3 +219,28 @@ environ_log(struct environ *env, const char *prefix)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Create initial environment for new child. */
|
||||
struct environ *
|
||||
environ_for_session(struct session *s)
|
||||
{
|
||||
struct environ *env;
|
||||
const char *value;
|
||||
int idx;
|
||||
|
||||
env = environ_create();
|
||||
environ_copy(global_environ, env);
|
||||
if (s != NULL)
|
||||
environ_copy(s->environ, env);
|
||||
|
||||
value = options_get_string(global_options, "default-terminal");
|
||||
environ_set(env, "TERM", "%s", value);
|
||||
|
||||
if (s != NULL)
|
||||
idx = s->id;
|
||||
else
|
||||
idx = -1;
|
||||
environ_set(env, "TMUX", "%s,%ld,%d", socket_path, (long)getpid(), idx);
|
||||
|
||||
return (env);
|
||||
}
|
||||
|
Reference in New Issue
Block a user