[vim/vim] Unix set_child_environment: setenv/putenv return values ignored for TERM/ROWS/LINES/COLUMNS (and related vars) (Issue #20823)

3 views
Skip to first unread message

Shixin Tan

unread,
Jul 23, 2026, 5:56:14 AM (yesterday) Jul 23
to vim/vim, Subscribed
tsx543 created an issue (vim/vim#20823)

Steps to reproduce

  1. Build Unix/POSIX Vim with job/terminal/shell support (normal default).
  2. Spawn an external command / job / :terminal so the child environment is set via set_child_environment() / set_default_child_environment() (e.g. :!ls, :terminal, or a job that inherits Vim’s tty size vars).
  3. Inspect src/os_unix.c: every setenv() / putenv() call discards its return value. If any call fails (typically ENOMEM), the child is still launched with a missing/stale TERM / ROWS / LINES / COLUMNS / COLORS / VIM_TERMINAL / VIM_SERVERNAME.
    Relevant code in current master (src/os_unix.c):
#ifdef HAVE_SETENV
    setenv("TERM", term, 1);
    ...
    setenv("ROWS", buf, 1);
    setenv("LINES", buf, 1);
    setenv("COLUMNS", buf, 1);
    ...
    /* COLORS / VIM_TERMINAL / VIM_SERVERNAME similarly unchecked */
#else
    /* putenv() fallback also ignores return values */
#endif

Callers include the default shell path and job/terminal startup in the same file (e.g. around the mch_call_shell / job-init paths that invoke set_child_environment()).

Expected behaviour

If setenv() / putenv() fails, Vim should surface an error (or otherwise abort the spawn path) instead of silently starting the child with an incomplete or stale terminal environment.

Version of Vim

9.2.0838

Environment

Operating system: Linux
Terminal: any
Value of $TERM: any
Shell: any

Logs and stack traces


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20823@github.com>

Reply all
Reply to author
Forward
0 new messages