Skip to main content

search_program

Function search_program 

Source
pub fn search_program(
    name: &OsStr,
    search: Option<&OsStr>,
    cwd: &AbsolutePath,
    error_name: impl Fn(i32) -> String,
) -> Option<ProgramSearch>
Expand description

Look up the program name in search, the value of PATH, or None when the environment has no PATH, for a program whose working directory is cwd. Each checked location is a probe whose outcome is ok when something is there, and otherwise the name that error_name gives the error number of the failed check, or unknown when the failure has no number.

A name with / is found at once, resolved against cwd, with nothing checked. An empty name is not found, with nothing checked.

Returns None when name has no / and search is None, since such a name cannot be looked up.