Skip to content

Commit

Permalink
avoid err if we can't resolve terminfo for TERM
Browse files Browse the repository at this point in the history
This patch will hopefully address #59. Unfortunately,
I wasn't able to write a test to reproduce the issue,
so it is just a blind fix.
  • Loading branch information
ethanpailes committed Jun 21, 2024
1 parent 15b6372 commit 0d22868
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions libshpool/src/daemon/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,22 +650,31 @@ impl Server {
.env_clear();

let term = self.inject_env(&mut cmd, &user_info, header).context("setting up shell env")?;
let fallback_terminfo = || {
match termini::TermInfo::from_name("xterm") {
Ok(db) => Ok(db),
Err(err) => {
warn!("could not get xterm terminfo: {:?}", err);
let empty_db = io::Cursor::new(vec![]);
termini::TermInfo::parse(empty_db).context("getting terminfo db")
}
}
};
let term_db = Arc::new(if let Some(term) = &term {
termini::TermInfo::from_name(term).context("resolving terminfo")?
match termini::TermInfo::from_name(term).context("resolving terminfo") {
Ok(ti) => ti,
Err(err) => {
warn!("could not get terminfo for '{}': {:?}", term, err);
fallback_terminfo()?
}
}
} else {
warn!("no $TERM, using default terminfo");
match termini::TermInfo::from_env() {
Ok(db) => db,
Err(err) => {
warn!("could not get terminfo from env: {:?}", err);
match termini::TermInfo::from_name("xterm") {
Ok(db) => db,
Err(err) => {
warn!("could not get xterm terminfo: {:?}", err);
let empty_db = io::Cursor::new(vec![]);
termini::TermInfo::parse(empty_db).context("getting terminfo db")?
}
}
fallback_terminfo()?
}
}
});
Expand Down

0 comments on commit 0d22868

Please sign in to comment.