From 785d784482936a15efda2cd32969f1466b848c88 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Mon, 5 Feb 2024 20:15:41 +0100 Subject: [PATCH] Make term warning less shouty We don't need to know that it tried these five before finally getting one, the list is *right there*. It is also very unlikely that someone has "xterm" or "ansi" but not "xterm-256color" For xterm-256color, we don't warn *at all* because we have that one hardcoded. --- src/env_dispatch.rs | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/env_dispatch.rs b/src/env_dispatch.rs index 19c31e652..e9bfd550c 100644 --- a/src/env_dispatch.rs +++ b/src/env_dispatch.rs @@ -518,17 +518,9 @@ fn initialize_curses_using_fallbacks(vars: &EnvStack) { // `term` here is one of our hard-coded strings above; we can unwrap because we can // guarantee it doesn't contain any interior NULs. - success = curses::setup(Some(&term), |term| apply_term_hacks(vars, term)).is_some(); - if is_interactive_session() { - if success { - FLOG!(warning, wgettext!("Using fallback terminal type"), term); - } else { - FLOG!( - warning, - wgettext!("Could not set up terminal using the fallback terminal type"), - term, - ); - } + success = curses::setup(Some(term), |term| apply_term_hacks(vars, term)).is_some(); + if is_interactive_session() && success { + FLOG!(warning, wgettext!("Using fallback terminal type"), term); } if success { @@ -661,15 +653,18 @@ fn init_curses(vars: &EnvStack) { if curses::setup(None, |term| apply_term_hacks(vars, term)).is_none() { if is_interactive_session() { let term = vars.get_unless_empty(L!("TERM")).map(|v| v.as_string()); - FLOG!(warning, wgettext!("Could not set up terminal.")); - if let Some(term) = term { - FLOG!(warning, wgettext!("TERM environment variable set to"), term); - FLOG!( - warning, - wgettext!("Check that this terminal type is supported on this system.") - ); - } else { - FLOG!(warning, wgettext!("TERM environment variable not set.")); + // We do not warn for xterm-256color at all, we know that one. + if term != Some("xterm-256color".into()) { + FLOG!(warning, wgettext!("Could not set up terminal.")); + if let Some(term) = term { + FLOG!(warning, wgettext!("TERM environment variable set to"), term); + FLOG!( + warning, + wgettext!("Check that this terminal type is supported on this system.") + ); + } else { + FLOG!(warning, wgettext!("TERM environment variable not set.")); + } } }