@@ -44,8 +44,13 @@ pub fn get_dbpath_for_term(term: &str) -> Option<~path> {
4444 dirs_to_search. push ( path ( i. to_owned ( ) ) ) ;
4545 }
4646 } ,
47- // Found nothing, use the default path
48- None => dirs_to_search. push ( path ( "/usr/share/terminfo" ) )
47+ // Found nothing, use the default paths
48+ // /usr/share/terminfo is the de facto location, but it seems
49+ // Ubuntu puts it in /lib/terminfo
50+ None => {
51+ dirs_to_search. push ( path ( "/usr/share/terminfo" ) ) ;
52+ dirs_to_search. push ( path ( "/lib/terminfo" ) ) ;
53+ }
4954 }
5055 }
5156 } ;
@@ -56,6 +61,11 @@ pub fn get_dbpath_for_term(term: &str) -> Option<~path> {
5661 if os:: path_exists ( p) && os:: path_exists ( newp) {
5762 return Some ( newp) ;
5863 }
64+ // on some installations the dir is named after the hex of the char (e.g. OS X)
65+ let newp = ~p. push_many ( & [ fmt ! ( "%x" , first_char[ 0 ] as uint) , term. to_owned ( ) ] ) ;
66+ if os:: path_exists ( p) && os:: path_exists ( newp) {
67+ return Some ( newp) ;
68+ }
5969 }
6070 None
6171}
@@ -72,6 +82,7 @@ pub fn open(term: &str) -> Result<@Reader, ~str> {
7282#[ ignore( reason = "buildbots don't have ncurses installed and I can't mock everything I need" ) ]
7383fn test_get_dbpath_for_term ( ) {
7484 // woefully inadequate test coverage
85+ // note: current tests won't work with non-standard terminfo hierarchies (e.g. OS X's)
7586 use std:: os:: { setenv, unsetenv} ;
7687 fn x ( t : & str ) -> ~str { get_dbpath_for_term ( t) . expect ( "no terminfo entry found" ) . to_str ( ) } ;
7788 assert ! ( x( "screen" ) == ~"/usr/share/terminfo/s/screen");
0 commit comments