diff options
author | James McCoy <jamessan@jamessan.com> | 2021-02-03 23:54:32 -0500 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2021-02-06 07:12:33 -0500 |
commit | 33f92fe025dc326020fbb953f8c042711016fea8 (patch) | |
tree | ec721c684c925dac096b5a6885e0cf9015538383 /src/nvim/channel.c | |
parent | f4f6cce952c1233136f243e76d096e3aaa0b1689 (diff) | |
download | rneovim-33f92fe025dc326020fbb953f8c042711016fea8.tar.gz rneovim-33f92fe025dc326020fbb953f8c042711016fea8.tar.bz2 rneovim-33f92fe025dc326020fbb953f8c042711016fea8.zip |
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.
Diffstat (limited to 'src/nvim/channel.c')
-rw-r--r-- | src/nvim/channel.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/nvim/channel.c b/src/nvim/channel.c index 5628ede2e6..09a34ca9fe 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -292,7 +292,6 @@ static void close_cb(Stream *stream, void *data) /// directory if `cwd` is NULL /// @param[in] pty_width Width of the pty, ignored if `pty` is false /// @param[in] pty_height Height of the pty, ignored if `pty` is false -/// @param[in] term_name `$TERM` for the pty /// @param[in] env Nvim's configured environment is used if this is NULL, /// otherwise defines all environment variables /// @param[out] status_out 0 for invalid arguments, > 0 for the channel id, @@ -304,8 +303,7 @@ Channel *channel_job_start(char **argv, CallbackReader on_stdout, bool pty, bool rpc, bool overlapped, bool detach, const char *cwd, uint16_t pty_width, uint16_t pty_height, - char *term_name, dict_T *env, - varnumber_T *status_out) + dict_T *env, varnumber_T *status_out) { assert(cwd == NULL || os_isdir_executable(cwd)); @@ -318,7 +316,9 @@ Channel *channel_job_start(char **argv, CallbackReader on_stdout, if (detach) { EMSG2(_(e_invarg2), "terminal/pty job cannot be detached"); shell_free_argv(argv); - xfree(term_name); + if (env) { + tv_dict_free(env); + } channel_destroy_early(chan); *status_out = 0; return NULL; @@ -330,9 +330,6 @@ Channel *channel_job_start(char **argv, CallbackReader on_stdout, if (pty_height > 0) { chan->stream.pty.height = pty_height; } - if (term_name) { - chan->stream.pty.term_name = term_name; - } } else { chan->stream.uv = libuv_process_init(&main_loop, chan); } @@ -362,9 +359,6 @@ Channel *channel_job_start(char **argv, CallbackReader on_stdout, if (proc->env) { tv_dict_free(proc->env); } - if (proc->type == kProcessTypePty) { - xfree(chan->stream.pty.term_name); - } channel_destroy_early(chan); *status_out = proc->status; return NULL; |