From dedadcfd30516c40692fe495a6ad10aea7c050de Mon Sep 17 00:00:00 2001 From: Rory Dudley Date: Mon, 20 May 2024 23:54:01 -0600 Subject: Added the 'which' built-in command Added a built-in which command (for MacOS and BSD), which can check aliases, and other shell built-in commands, in addition to bins on the $PATH. --- src/poem/anthology.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/poem/anthology.rs') diff --git a/src/poem/anthology.rs b/src/poem/anthology.rs index 7766f62..8ff70f9 100644 --- a/src/poem/anthology.rs +++ b/src/poem/anthology.rs @@ -3,12 +3,13 @@ mod cd; mod exit; mod export; mod source; +mod which; use crate::compose::Environment; use crate::poem::Verse; /// A static list of all the built-in commands -static INDEX: [&str; 7] = [ - "alias", "cd", "exit", "export", "source", "unalias", "unset", +static INDEX: [&str; 8] = [ + "alias", "cd", "exit", "export", "source", "unalias", "unset", "which", ]; /// Lookup the index of a built-in command @@ -53,6 +54,7 @@ pub fn incant(verse: &Verse, out: &mut Vec, index: usize, env: &mut Environm "source" => source::incant(verse, out, env), "unalias" => alias::unincant(verse, &mut env.aliases), "unset" => export::unincant(verse), + "which" => which::incant(verse, out, env), _ => unreachable!(), } } -- cgit v1.2.3