aboutsummaryrefslogtreecommitdiffstats
path: root/src/run
diff options
context:
space:
mode:
authorJonas Maier <>2026-03-08 08:52:19 +0100
committerJonas Maier <>2026-03-08 08:52:19 +0100
commit0a1b056c7ae1caca44eba8d3073c46f7263f36ba (patch)
tree1a59e08a36d5385a6c4907f24d2f8375c56c3792 /src/run
parent5dd3abb3b4642cd42e532805a8b0c334025c0d10 (diff)
downloadpish-0a1b056c7ae1caca44eba8d3073c46f7263f36ba.tar.gz
make type better
Diffstat (limited to 'src/run')
-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(())