Fix crash with empty $TERM

```
~ $ set -e TERM; fish
Assertion failed: (!is_missing), function c_str, file src/env.cpp, line 690.
fish: 'fish' terminated by signal SIGABRT (Abort)
```
This commit is contained in:
Aaron Gyes 2016-06-21 10:28:04 -07:00 committed by Kurtis Rader
parent eb834f47ef
commit ecf4517ffe

View File

@ -464,8 +464,13 @@ int input_init() {
int err_ret;
if (setupterm(NULL, STDOUT_FILENO, &err_ret) == ERR) {
env_var_t term = env_get_string(L"TERM");
debug(0, _(L"Your TERM value of '%ls' is not valid"), term.c_str());
debug(0, _(L"Check that your terminal type is supported on this system"));
if (term.missing_or_empty()) {
debug(0, _(L"Your TERM is unset or empty."));
} else {
debug(0, _(L"Your TERM value of '%ls' is not valid"), term.c_str());
debug(0, _(L"Check that your terminal type is supported on this system"));
}
env_set(L"TERM", DEFAULT_TERM, ENV_GLOBAL | ENV_EXPORT);
if (setupterm(NULL, STDOUT_FILENO, &err_ret) == ERR) {
debug(0, _(L"Unable to setup terminal using your TERM or the '%ls' fallback"),