The CHECK_TERM_ENV macro returns !NonEmpty(term_env), i.e. true if term_env **is** empty. Negating the return value again causes setupterm to mailfunction. diff -upr ncurses-6.2-20200906.orig/ncurses/tinfo/lib_setup.c ncurses-6.2-20200906/ncurses/tinfo/lib_setup.c --- ncurses-6.2-20200906.orig/ncurses/tinfo/lib_setup.c 2020-09-07 11:28:05.041642395 +0200 +++ ncurses-6.2-20200906/ncurses/tinfo/lib_setup.c 2020-09-07 11:28:32.087989409 +0200 @@ -667,7 +667,7 @@ TINFO_SETUP_TERM(TERMINAL **tp, if (!NonEmpty(tname)) tname = "unknown"; #else - if (!CHECK_TERM_ENV(tname, NO_TERMINAL)) { + if (CHECK_TERM_ENV(tname, NO_TERMINAL)) { T(("Failure with TERM=%s", tname)); ret_error0(TGETENT_ERR, "TERM environment variable not set.\n"); }