don't export COLUMNS/LINES unless already exported

Fixes #3839
This commit is contained in:
Kurtis Rader 2017-02-10 15:20:09 -08:00
parent 3e35e6e488
commit 0a929f7a0b
2 changed files with 8 additions and 4 deletions

View file

@ -1415,10 +1415,13 @@ static void validate_new_termsize(struct winsize *new_termsize) {
/// Export the new terminal size as env vars and to the kernel if possible. /// Export the new terminal size as env vars and to the kernel if possible.
static void export_new_termsize(struct winsize *new_termsize) { static void export_new_termsize(struct winsize *new_termsize) {
wchar_t buf[64]; wchar_t buf[64];
env_var_t cols = env_get_string(L"COLUMNS", ENV_EXPORT);
swprintf(buf, 64, L"%d", (int)new_termsize->ws_col); swprintf(buf, 64, L"%d", (int)new_termsize->ws_col);
env_set(L"COLUMNS", buf, ENV_EXPORT | ENV_GLOBAL); env_set(L"COLUMNS", buf, ENV_GLOBAL | (cols.missing_or_empty() ? 0 : ENV_EXPORT));
env_var_t lines = env_get_string(L"LINES", ENV_EXPORT);
swprintf(buf, 64, L"%d", (int)new_termsize->ws_row); swprintf(buf, 64, L"%d", (int)new_termsize->ws_row);
env_set(L"LINES", buf, ENV_EXPORT | ENV_GLOBAL); env_set(L"LINES", buf, ENV_GLOBAL | (lines.missing_or_empty() ? 0 : ENV_EXPORT));
#ifdef HAVE_WINSIZE #ifdef HAVE_WINSIZE
ioctl(STDOUT_FILENO, TIOCSWINSZ, new_termsize); ioctl(STDOUT_FILENO, TIOCSWINSZ, new_termsize);

View file

@ -474,9 +474,10 @@ static void setup_path() {
/// adjusted. /// adjusted.
static void env_set_termsize() { static void env_set_termsize() {
env_var_t cols = env_get_string(L"COLUMNS"); env_var_t cols = env_get_string(L"COLUMNS");
if (cols.missing_or_empty()) env_set(L"COLUMNS", DFLT_TERM_COL_STR, ENV_EXPORT | ENV_GLOBAL); if (cols.missing_or_empty()) env_set(L"COLUMNS", DFLT_TERM_COL_STR, ENV_GLOBAL);
env_var_t rows = env_get_string(L"LINES"); env_var_t rows = env_get_string(L"LINES");
if (rows.missing_or_empty()) env_set(L"LINES", DFLT_TERM_ROW_STR, ENV_EXPORT | ENV_GLOBAL); if (rows.missing_or_empty()) env_set(L"LINES", DFLT_TERM_ROW_STR, ENV_GLOBAL);
} }
bool env_set_pwd() { bool env_set_pwd() {