fix(pty): Always use $TERM from the job's env dict

Before #12937, the only way to specify the `$TERM` for a pty job was
through the `TERM` key in the job's opts dict.  This was shuttled to the
child process throug a special field on the PtyProcess object and
injected into the environment after forking.

Now that we have a proper way to specify the environment for a job, we
can simply ensure that the env dict has a proper `TERM` set and avoid
the extra shuttling of data around.

This deprecates the use of the `TERM` option, but will still honor it if
present, although at a lower priority than a `TERM` present in the env
dict.

This also fixes #13874 because we're no longer trying to overwrite
`TERM` in the env dict with the special pty `term_name`.  Doing so
raises an internal error because of the existing key which, under
certain circumstances, would cause the "hit enter" prompt.  However,
since the child process had already forked, there was no way for the
user to acknowledge the prompt and we would just hang there.
This commit is contained in:
James McCoy
2021-02-03 23:54:32 -05:00
parent f4f6cce952
commit 33f92fe025
7 changed files with 30 additions and 27 deletions

View File

@@ -182,8 +182,6 @@ static void init_child(PtyProcess *ptyproc)
char *prog = ptyproc->process.argv[0];
assert(proc->env);
tv_dict_add_str(proc->env, S_LEN("TERM"),
ptyproc->term_name ? ptyproc->term_name : "ansi");
environ = tv_dict_to_env(proc->env);
execvp(prog, proc->argv);
ELOG("execvp failed: %s: %s", strerror(errno), prog);