Do not update TERM into config file parsing has finished.

This commit is contained in:
nicm 2017-04-25 15:35:10 +00:00
parent 4a51a9d9d5
commit c48d09ec88
7 changed files with 16 additions and 9 deletions

View File

@ -77,7 +77,7 @@ cmd_respawn_pane_exec(struct cmd *self, struct cmdq_item *item)
if (envent != NULL)
path = envent->value;
env = environ_for_session(s);
env = environ_for_session(s, 0);
if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, NULL, env,
s->tio, &cause) != 0) {
cmdq_error(item, "respawn pane failed: %s", cause);

View File

@ -81,7 +81,7 @@ cmd_respawn_window_exec(struct cmd *self, struct cmdq_item *item)
if (envent != NULL)
path = envent->value;
env = environ_for_session(s);
env = environ_for_session(s, 0);
if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, NULL, env,
s->tio, &cause) != 0) {
cmdq_error(item, "respawn window failed: %s", cause);

View File

@ -144,7 +144,7 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
if (envent != NULL)
path = envent->value;
env = environ_for_session(s);
env = environ_for_session(s, 0);
if (window_pane_spawn(new_wp, argc, argv, path, shell, cwd, env,
s->tio, &cause) != 0) {
environ_free(env);

View File

@ -222,7 +222,7 @@ environ_log(struct environ *env, const char *prefix)
/* Create initial environment for new child. */
struct environ *
environ_for_session(struct session *s)
environ_for_session(struct session *s, int no_TERM)
{
struct environ *env;
const char *value;
@ -233,8 +233,10 @@ environ_for_session(struct session *s)
if (s != NULL)
environ_copy(s->environ, env);
value = options_get_string(global_options, "default-terminal");
environ_set(env, "TERM", "%s", value);
if (!no_TERM) {
value = options_get_string(global_options, "default-terminal");
environ_set(env, "TERM", "%s", value);
}
if (s != NULL)
idx = s->id;

7
job.c
View File

@ -55,7 +55,12 @@ job_run(const char *cmd, struct session *s, const char *cwd,
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, out) != 0)
return (NULL);
env = environ_for_session(s);
/*
* Do not set TERM during .tmux.conf, it is nice to be able to use
* if-shell to decide on default-terminal based on outside TERM.
*/
env = environ_for_session(s, !cfg_finished);
switch (pid = fork()) {
case -1:
environ_free(env);

View File

@ -360,7 +360,7 @@ session_new(struct session *s, const char *name, int argc, char **argv,
shell = _PATH_BSHELL;
hlimit = options_get_number(s->options, "history-limit");
env = environ_for_session(s);
env = environ_for_session(s, 0);
w = window_create_spawn(name, argc, argv, path, shell, cwd, env, s->tio,
s->sx, s->sy, hlimit, cause);
if (w == NULL) {

2
tmux.h
View File

@ -1612,7 +1612,7 @@ void environ_unset(struct environ *, const char *);
void environ_update(struct options *, struct environ *, struct environ *);
void environ_push(struct environ *);
void environ_log(struct environ *, const char *);
struct environ *environ_for_session(struct session *);
struct environ *environ_for_session(struct session *, int);
/* tty.c */
void tty_create_log(void);