Browse Source

feat: add segfault command

main
fdai7451 2 years ago
parent
commit
a485583db2
  1. 2
      src/builtins/mod.rs
  2. 11
      src/builtins/segfault.rs

2
src/builtins/mod.rs

@ -9,6 +9,7 @@ mod fetch;
mod ls;
mod open;
mod pwd;
mod segfault;
pub struct BuiltinConfig {
pub prompt_style: PromptStyle,
@ -35,6 +36,7 @@ const BUILTINS: Lazy<Vec<(&str, Box<dyn Builtin>)>> = Lazy::new(|| {
("open", Box::new(open::Open)),
("fetch", Box::new(fetch::Fetch)),
("ls", Box::new(ls::Ls)),
("segfault", Box::new(segfault::Segfault)),
]
});

11
src/builtins/segfault.rs

@ -0,0 +1,11 @@
use crate::builtins::{Builtin, BuiltinConfig};
use crate::error::ShellError;
pub struct Segfault;
impl Builtin for Segfault {
fn execute(&mut self, _: &mut BuiltinConfig, _: Vec<String>) -> Result<(), ShellError> {
unsafe { std::ptr::null_mut::<i32>().write(69) };
Ok(())
}
}
Loading…
Cancel
Save