From 2c39d5b6c00f6f73af1342eb8f76866aae4de1a3 Mon Sep 17 00:00:00 2001 From: David Adam Date: Tue, 26 Nov 2013 11:39:54 +0800 Subject: [PATCH] fall back to ANSI terminal type if setupterm fails Closes: https://github.com/fish-shell/fish-shell/issues/1060 'ansi' should always be present (tested on Solaris, Linux, FreeBSD, Darwin). Also overrides TERM so that other programs behave consistently e.g. fish_pager. The error message makes no specific mention of terminfo or termcap as these vary across operating systems. (r+ @ridiculousfish with thanks) --- input.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/input.cpp b/input.cpp index 7b63db1de..12f7580d6 100644 --- a/input.cpp +++ b/input.cpp @@ -60,6 +60,8 @@ #include "intern.h" #include +#define DEFAULT_TERM L"ansi" + /** Struct representing a keybinding. Returned by input_get_mappings. */ @@ -355,8 +357,19 @@ int input_init() { debug(0, _(L"Check that your terminal type, '%ls', is supported on this system"), term.c_str()); + debug(0, _(L"Attempting to use '%ls' instead"), DEFAULT_TERM); + env_set(L"TERM", DEFAULT_TERM, ENV_GLOBAL | ENV_EXPORT); + const std::string default_term = wcs2string(DEFAULT_TERM); + if (setupterm(default_term.c_str(), STDOUT_FILENO, &errret) == ERR) + { + debug(0, _(L"Could not set up terminal")); + exit_without_destructors(1); + } + } + else + { + exit_without_destructors(1); } - exit_without_destructors(1); } assert(! term.missing()); output_set_term(term);