aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/run/builtin.rs20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/run/builtin.rs b/src/run/builtin.rs
index 4f7b9ed..5a0c777 100644
--- a/src/run/builtin.rs
+++ b/src/run/builtin.rs
@@ -203,19 +203,15 @@ impl Builtin for _type {
stdout: &mut dyn Write,
) -> Result {
for arg in args {
- let mut kind = String::from("not found");
- {
- let _se = session.lock().unwrap();
- // TODO: look up functions in session
-
- for b in super::BUILTINS {
- if b.name().as_bytes() == &arg[..] {
- kind = String::from("builtin");
- break;
- }
- }
+ let kind = super::get_command_kind(&session.lock().unwrap(), &arg[..]);
+
+ let kind_str = match kind {
+ run::CommandKind::Builtin(_) => "builtin",
+ run::CommandKind::Fun(_) => "function",
+ run::CommandKind::Path(_) => "command (if it exists)",
};
- writeln!(stdout, "{} is {}", String::from_utf8_lossy(arg), kind)?;
+
+ writeln!(stdout, "{} is {}", String::from_utf8_lossy(arg), kind_str)?;
}
Ok(())