pub fn resolve_terminfo_dirs() -> Option<String> {
    // Always respect an environment variable, if present.
    if std::env::var("TERMINFO_DIRS").is_ok() {
        return None;
    }

    let os_info = resolve_os_info();

    match os_info.os {
        OsVariant::Linux => match os_info.linux_distro.unwrap() {
            // TODO we could stat() the well-known paths ourselves and omit
            // paths that don't exist. This /might/ save some syscalls, since
            // ncurses doesn't appear to be the most frugal w.r.t. filesystem
            // requests.
            LinuxDistroVariant::Debian => Some(TERMINFO_DIRS_DEBIAN.to_string()),
            LinuxDistroVariant::RedHat => Some(TERMINFO_DIRS_REDHAT.to_string()),
            LinuxDistroVariant::Unknown => {
                // We don't know this Linux variant. Look for common terminfo
                // database directories and use paths that are found.
                let paths = TERMINFO_DIRS_COMMON
                    .iter()
                    .filter_map(|p| {
                        if p.exists() {
                            Some(p.display().to_string())
                        } else {
                            None
                        }
                    })
                    .collect::<Vec<String>>()
                    .join(":");

                Some(paths)
            }
        },
        OsVariant::MacOs => Some(TERMINFO_DIRS_MACOS.to_string()),
        // Windows doesn't use the terminfo database.
        OsVariant::Windows => None,
        OsVariant::Other => None,
    }
}
/// Attempt to resolve the value for the `TERMINFO_DIRS` environment variable.
///
/// Returns Some() value that `TERMINFO_DIRS` should be set to or None if
/// no environment variable should be set.
Attempt to resolve the value for the `TERMINFO_DIRS` environment variable.
Returns Some() value that `TERMINFO_DIRS` should be set to or None if
no environment variable should be set.
Attempt to resolve the value for the ` TERMINFO_DIRS ` environment variable . Returns Some () value that ` TERMINFO_DIRS ` should be set to or None if no environment variable should be set .
pub fn resolve_terminfo_dirs() -> Option<String> {
    // Always respect an environment variable, if present.
    if std::env::var("TERMINFO_DIRS").is_ok() {
        return None;
    }
    let os_info = resolve_os_info();
    match os_info.os {
        OsVariant::Linux => match os_info.linux_distro.unwrap() {
            // TODO we could stat() the well-known paths ourselves and omit
            // paths that don't exist. This /might/ save some syscalls, since
            // ncurses doesn't appear to be the most frugal w.r.t. filesystem
            // requests.
            LinuxDistroVariant::Debian => Some(TERMINFO_DIRS_DEBIAN.to_string()),
            LinuxDistroVariant::RedHat => Some(TERMINFO_DIRS_REDHAT.to_string()),
            LinuxDistroVariant::Unknown => {
                // We don't know this Linux variant. Look for common terminfo
                // database directories and use paths that are found.
                let paths = TERMINFO_DIRS_COMMON
                    .iter()
                    .filter_map(|p| {
                        if p.exists() {
                            Some(p.display().to_string())
                        } else {
                            None
                        }
                    })
                    .collect::<Vec<String>>()
                    .join(":");
                Some(paths)
            }
        },
        OsVariant::MacOs => Some(TERMINFO_DIRS_MACOS.to_string()),
        // Windows doesn't use the terminfo database.
        OsVariant::Windows => None,
        OsVariant::Other => None,
    }
}
pub fn resolve_terminfo_dirs ( ) -> Option < String > { // Always respect an environment variable, if present. if std :: env :: var ( " " ) . is_ok ( ) { return None ; } let os_info = resolve_os_info ( ) ; match os_info . os { OsVariant :: Linux => match os_info . linux_distro . unwrap ( ) { // TODO we could stat() the well-known paths ourselves and omit // paths that don't exist. This /might/ save some syscalls, since // ncurses doesn't appear to be the most frugal w.r.t. filesystem // requests. LinuxDistroVariant :: Debian => Some ( TERMINFO_DIRS_DEBIAN . to_string ( ) ) , LinuxDistroVariant :: RedHat => Some ( TERMINFO_DIRS_REDHAT . to_string ( ) ) , LinuxDistroVariant :: Unknown => { // We don't know this Linux variant. Look for common terminfo // database directories and use paths that are found. let paths = TERMINFO_DIRS_COMMON . iter ( ) . filter_map ( | p | { if p . exists ( ) { Some ( p . display ( ) . to_string ( ) ) } else { None } } ) . collect :: < Vec < String > > ( ) . join ( " " ) ; Some ( paths ) } } , OsVariant :: MacOs => Some ( TERMINFO_DIRS_MACOS . to_string ( ) ) , // Windows doesn't use the terminfo database. OsVariant :: Windows => None , OsVariant :: Other => None , } }
Attempt to resolve the value for the `TERMINFO_DIRS` environment variable.
Attempt to resolve the value for the ` TERMINFO_DIRS ` environment variable .