diff --git a/src/builtins/exit.rs b/src/builtins/exit.rs new file mode 100644 index 0000000..dd56735 --- /dev/null +++ b/src/builtins/exit.rs @@ -0,0 +1,5 @@ +use crate::error::ShellError; + +pub fn run() -> Result<(), ShellError> { + Err(ShellError::Exit) +} \ No newline at end of file diff --git a/src/builtins/mod.rs b/src/builtins/mod.rs index f324863..56adceb 100644 --- a/src/builtins/mod.rs +++ b/src/builtins/mod.rs @@ -1,7 +1,8 @@ use crate::error::ShellError; mod cd; +mod exit; -const BUILTINS: &[&str] = &["cd"]; +const BUILTINS: &[&str] = &["exit", "cd"]; pub fn is_builtin(keyword: &str) -> bool { BUILTINS.contains(&keyword) @@ -9,6 +10,7 @@ pub fn is_builtin(keyword: &str) -> bool { pub fn execute_builtin(keyword: &str, args: &[&str]) -> Result<(), ShellError> { match keyword { + "exit" => exit::run()?, "cd" => cd::run(args)?, _ => {} }