Skip to content

Commit b33873f

Browse files
authored
Auto merge of #37469 - meh:fix-term, r=alexcrichton
Fix terminfo database search path This is more consistent with what every other program does, I happened to have `TERMINFO` set as `/usr/share/terminfo` but had the actual database in `~/.terminfo`, regardless of that every other terminfo/ncurses based software picked up the one in the home correctly. This just puts the path in `TERMINFO` at the top of the search paths, and moves the home checking to the default search paths section.
2 parents 391939b + f9cc166 commit b33873f

File tree

1 file changed

+26
-30
lines changed

1 file changed

+26
-30
lines changed

src/libterm/terminfo/searcher.rs

+26-30
Original file line numberDiff line numberDiff line change
@@ -26,38 +26,34 @@ pub fn get_dbpath_for_term(term: &str) -> Option<PathBuf> {
2626
};
2727

2828
// Find search directory
29-
match env::var_os("TERMINFO") {
30-
Some(dir) => dirs_to_search.push(PathBuf::from(dir)),
31-
None => {
32-
if let Some(mut homedir) = env::home_dir() {
33-
// ncurses compatibility;
34-
homedir.push(".terminfo");
35-
dirs_to_search.push(homedir)
36-
}
37-
match env::var("TERMINFO_DIRS") {
38-
Ok(dirs) => {
39-
for i in dirs.split(':') {
40-
if i == "" {
41-
dirs_to_search.push(PathBuf::from("/usr/share/terminfo"));
42-
} else {
43-
dirs_to_search.push(PathBuf::from(i));
44-
}
45-
}
46-
}
47-
// Found nothing in TERMINFO_DIRS, use the default paths:
48-
// According to /etc/terminfo/README, after looking at
49-
// ~/.terminfo, ncurses will search /etc/terminfo, then
50-
// /lib/terminfo, and eventually /usr/share/terminfo.
51-
// On Haiku the database can be found at /boot/system/data/terminfo
52-
Err(..) => {
53-
dirs_to_search.push(PathBuf::from("/etc/terminfo"));
54-
dirs_to_search.push(PathBuf::from("/lib/terminfo"));
55-
dirs_to_search.push(PathBuf::from("/usr/share/terminfo"));
56-
dirs_to_search.push(PathBuf::from("/boot/system/data/terminfo"));
57-
}
29+
if let Some(dir) = env::var_os("TERMINFO") {
30+
dirs_to_search.push(PathBuf::from(dir));
31+
}
32+
33+
if let Ok(dirs) = env::var("TERMINFO_DIRS") {
34+
for i in dirs.split(':') {
35+
if i == "" {
36+
dirs_to_search.push(PathBuf::from("/usr/share/terminfo"));
37+
} else {
38+
dirs_to_search.push(PathBuf::from(i));
5839
}
5940
}
60-
};
41+
} else {
42+
// Found nothing in TERMINFO_DIRS, use the default paths:
43+
// According to /etc/terminfo/README, after looking at
44+
// ~/.terminfo, ncurses will search /etc/terminfo, then
45+
// /lib/terminfo, and eventually /usr/share/terminfo.
46+
// On Haiku the database can be found at /boot/system/data/terminfo
47+
if let Some(mut homedir) = env::home_dir() {
48+
homedir.push(".terminfo");
49+
dirs_to_search.push(homedir)
50+
}
51+
52+
dirs_to_search.push(PathBuf::from("/etc/terminfo"));
53+
dirs_to_search.push(PathBuf::from("/lib/terminfo"));
54+
dirs_to_search.push(PathBuf::from("/usr/share/terminfo"));
55+
dirs_to_search.push(PathBuf::from("/boot/system/data/terminfo"));
56+
}
6157

6258
// Look for the terminal in all of the search directories
6359
for mut p in dirs_to_search {

0 commit comments

Comments
 (0)