diff --git a/src/env_dispatch.cpp b/src/env_dispatch.cpp index 588dc90ee..f989dbe6c 100644 --- a/src/env_dispatch.cpp +++ b/src/env_dispatch.cpp @@ -491,6 +491,11 @@ static void initialize_curses_using_fallbacks(const environment_t &vars) { // Apply any platform-specific hacks to cur_term/ static void apply_term_hacks(const environment_t &vars) { UNUSED(vars); + // Be careful, variables like "enter_italics_mode" are #defined to dereference through cur_term. + // See #8876. + if (!cur_term) { + return; + } #ifdef __APPLE__ // Hack in missing italics and dim capabilities omitted from MacOS xterm-256color terminfo // Helps Terminal.app/iTerm diff --git a/tests/pexpects/nullterm.py b/tests/pexpects/nullterm.py new file mode 100644 index 000000000..1e87386d2 --- /dev/null +++ b/tests/pexpects/nullterm.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +import os +from pexpect_helper import SpawnedProc + +# Regression test for #8873. +# fish doesn't crash if TERM is unset. +env = os.environ.copy() +env.pop("TERM", None) + +sp = SpawnedProc(env=env) +sendline, expect_prompt = sp.sendline, sp.expect_prompt + +expect_prompt() +sendline("set_color --italics") +expect_prompt() +sendline("set_color normal") +expect_prompt()