use is_executable::IsExecutable;
use std::path::{Path, PathBuf};
pub fn scan_path<S>(exename: S) -> anyhow::Result<Vec<PathBuf>>
where
S: AsRef<Path>,
{
let mut found = vec![];
for dir in std::env::var("PATH")?.split(':') {
let dir: &Path = dir.as_ref();
let candidate = dir.join(exename.as_ref());
if candidate.is_executable() {
found.push(candidate.canonicalize()?);
}
}
Ok(found)
}