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