From dcee6da16a233d359e4672109f5dc60e157b89a6 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Sun, 3 Mar 2019 18:24:04 -0800 Subject: [PATCH] ncurses: panic with error message if $TERM is unset --- src/backend/curses/n.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/backend/curses/n.rs b/src/backend/curses/n.rs index 942121f..f535bc3 100644 --- a/src/backend/curses/n.rs +++ b/src/backend/curses/n.rs @@ -59,6 +59,14 @@ fn write_to_tty(bytes: &[u8]) -> io::Result<()> { impl Backend { /// Creates a new ncurses-based backend. pub fn init() -> Box { + // 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, "");