diff options
author | David Adam <zanchey@ucc.gu.uwa.edu.au> | 2013-11-26 11:39:54 +0800 |
---|---|---|
committer | David Adam <zanchey@ucc.gu.uwa.edu.au> | 2013-11-26 21:56:49 +0800 |
commit | 2c39d5b6c00f6f73af1342eb8f76866aae4de1a3 (patch) | |
tree | 748b5f36b4f790b613ac7fb7c2470902f938208c /input.cpp | |
parent | 8d1667e9e8a7ad941419b017e9118d3f2c3f5af7 (diff) |
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)
Diffstat (limited to 'input.cpp')
-rw-r--r-- | input.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -60,6 +60,8 @@ #include "intern.h" #include <vector> +#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); |