diff --git a/src/builtins/mod.rs b/src/builtins/mod.rs new file mode 100644 index 0000000..cd4a7d1 --- /dev/null +++ b/src/builtins/mod.rs @@ -0,0 +1,11 @@ +use crate::error::ShellError; + +const BUILTINS: &[&str] = &[]; + +pub fn is_builtin(keyword: &str) -> bool { + BUILTINS.contains(&keyword) +} + +pub fn execute_builtin(keyword: &str, args: &[&str]) -> Result<(), ShellError> { + Ok(()) +} diff --git a/src/execute.rs b/src/execute.rs index 3a54865..8cc28bf 100644 --- a/src/execute.rs +++ b/src/execute.rs @@ -1,6 +1,7 @@ use std::io::ErrorKind::NotFound; use std::process::Command; +use crate::builtins::{execute_builtin, is_builtin}; use crate::error::ShellError; use crate::parse::parse_line; @@ -10,10 +11,14 @@ pub fn interpret(line: &str) -> Result<(), ShellError> { } let (keyword, args) = parse_line(line); - let mut command = Command::new(keyword); - command.args(args); + if is_builtin(keyword) { + execute_builtin(keyword, &args)?; + } else { + let mut command = Command::new(keyword); + command.args(args); - execute(command)?; + execute(command)?; + } Ok(()) } diff --git a/src/main.rs b/src/main.rs index 237c641..c19774c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +mod builtins; mod error; mod execute; mod parse;