From 1a7acb4e391b86640f8736fd901653562c5669a9 Mon Sep 17 00:00:00 2001 From: Avril Date: Mon, 1 Jun 2020 18:38:40 +0100 Subject: [PATCH] program-specific path --- src/arg/proc_args.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/arg/proc_args.rs b/src/arg/proc_args.rs index eb3543c..15e0dd9 100644 --- a/src/arg/proc_args.rs +++ b/src/arg/proc_args.rs @@ -41,16 +41,23 @@ impl ProcessArgs pub fn verify(&self) -> Result { + 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, V: AsRef { let name = name.as_ref(); - - let pbuf = Path::new(&name); - if pbuf.exists() { - return Some(pbuf.to_owned()) - } for place in places {