fix: provide a convenient message if TERM isn't set

This commit is contained in:
Kate Temkin 2024-05-05 16:46:41 -06:00
parent 9038c2e7b8
commit 83960c7814

View file

@ -1,4 +1,5 @@
use std::{ use std::{
io::{stdout, Write},
os::unix::prelude::PermissionsExt, os::unix::prelude::PermissionsExt,
path::{Path, PathBuf}, path::{Path, PathBuf},
process::ExitCode, process::ExitCode,
@ -80,6 +81,22 @@ impl CommandExecute for Install {
explain, explain,
} = self; } = self;
// Get our terminal object, explaining what to do if it's not there.
let term =
term::terminfo::TerminfoTerminal::new(stdout());
if term.is_none() && !no_confirm {
eprintln!(
"{}",
format!("\
\n\
Couldn't figure out which terminal you're using -- check the value of the $TERM variable.\n\n\
If you're using an interactive terminal, it's probably safe to set TERM to \"xterm\",\n\
by e.g. running 'export TERM=xterm'.\n\
").red()
);
interaction::clean_exit_with_message("Couldn't get the terminal! Aborting.").await;
}
ensure_root()?; ensure_root()?;
let existing_receipt: Option<InstallPlan> = match Path::new(RECEIPT_LOCATION).exists() { let existing_receipt: Option<InstallPlan> = match Path::new(RECEIPT_LOCATION).exists() {