ncurses: panic with error message if $TERM is unset
@@ -59,6 +59,14 @@ fn write_to_tty(bytes: &[u8]) -> io::Result<()> {
impl Backend {
/// Creates a new ncurses-based backend.
pub fn init() -> Box<dyn backend::Backend> {
+ // Check the $TERM variable.
+ if std::env::var("TERM")
+ .map(|var| var.is_empty())
+ .unwrap_or(true)
+ {
+ panic!("$TERM is unset. Cannot initialize ncurses interface.");
+ }
+
// Change the locale.
// For some reasons it's mandatory to get some UTF-8 support.
ncurses::setlocale(ncurses::LcCategory::all, "");
