diff options
Diffstat (limited to 'src/poem/anthology/which.rs')
-rw-r--r-- | src/poem/anthology/which.rs | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/poem/anthology/which.rs b/src/poem/anthology/which.rs index 6fe709c..0872dda 100644 --- a/src/poem/anthology/which.rs +++ b/src/poem/anthology/which.rs @@ -1,4 +1,5 @@ use crate::compose::Environment; +use crate::poem::elements::verse::Spelling; use crate::poem::Verse; use std::os::unix::process::ExitStatusExt; use std::process::{ExitStatus, Output}; @@ -22,26 +23,28 @@ pub fn incant(clause: &Option<Vec<String>>, uout: bool, uerr: bool, env: &Enviro continue; } - // Check if it's a built-in - match super::lookup(&word) { - Some(_) => { + // Manually check the path + let mut verb = Verse::new(); + verb.push(word.clone()); + match verb.spellcheck(&env.bins) { + Some(Spelling::OnPath(i)) => { + output = format!("{}\n", env.bins[i]); + if uout { + out.append(&mut output.as_bytes().to_vec()); + } else { + print!("{}", output); + } + } + Some(Spelling::BuiltIn(_)) => { output = format!("{}: shell built-in command\n", word); if uout { out.append(&mut output.as_bytes().to_vec()); } else { print!("{}", output); } - continue; } - None => {} - } - - // Manually check the path - let mut verb = Verse::new(); - verb.push(word.clone()); - match verb.spellcheck(&env.bins) { - Some(i) => { - output = format!("{}\n", env.bins[i]); + Some(Spelling::FullPath) => { + output = format!("{}\n", word); if uout { out.append(&mut output.as_bytes().to_vec()); } else { |