diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/main.rs b/src/main.rs index 403fd33..01e5fbd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,23 +1,26 @@ -use std::process::Command; -use std::process::Stdio; +use std::process::{Command, Stdio}; mod builtins; mod prompt; +fn sigint_handler(dummy: i32) { + println!("sigint_handler: {}", dummy); +} + fn main() { + + unsafe { + // capture Ctrl+C (SIGINT) + libc::signal(libc::SIGINT, sigint_handler as libc::sighandler_t); + } + match std::fs::read_to_string("/etc/motd") { - Ok(motd) => println!("{}", motd), + Ok(motd) => print!("{}", motd), Err(_) => {} } - let prompt = match prompt::Prompt::new() { - Ok(p) => p, - Err(e) => panic!(e), - }; - let mut cwd = match std::env::current_dir() { - Ok(p) => p, - Err(e) => panic!(e), - }; + let prompt = prompt::Prompt::new().unwrap(); + let mut cwd = std::env::current_dir().unwrap(); loop { prompt.print(&cwd); @@ -91,4 +94,5 @@ fn main() { } } } // loop + } |