program-specific path

master
Avril 5 years ago
parent a9cf444d39
commit 1a7acb4e39
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -41,16 +41,23 @@ impl ProcessArgs
pub fn verify(&self) -> Result<PathBuf, &'static str>
{
if let Ok(spath) = std::env::var("LEAKY_PIPE_PATH") {
if let Some(path) = find_somewhere(&self.name, spath.split(':')) {
return Ok(path)
}
}
if let Ok(spath) = std::env::var("PATH") {
if let Some(path) = find_somewhere(&self.name, spath.split(':')) {
Ok(path)
} else {
Err("File not found")
}
} else if Path::new(&self.name).exists() {
Ok(Path::new(&self.name).to_owned())
} else {
Err("File not found and $PATH not found.")
match Path::new(&self.name) {
path if path.exists() => Ok(Path::new(&self.name).to_owned()),
_ => Err("File not found and $PATH not found.")
}
}
}
}
@ -61,11 +68,6 @@ where T: AsRef<str>,
V: AsRef<str>
{
let name = name.as_ref();
let pbuf = Path::new(&name);
if pbuf.exists() {
return Some(pbuf.to_owned())
}
for place in places
{

Loading…
Cancel
Save