diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index a4f3c25..0581b13 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,12 +5,19 @@ mod builtins; mod prompt; fn main() { - println!("rshell motd"); + match std::fs::read_to_string("/etc/motd") { + Ok(motd) => println!("{}", motd), + Err(_) => {}, + } - let mut prompt = prompt::Prompt::new(); + let prompt = prompt::Prompt::new(); + let mut cwd = match std::env::current_dir() { + Ok(p) => p, + Err(e) => panic!(e), + }; loop { - prompt.print(); + prompt.print(&cwd); let mut input = String::new(); match std::io::stdin().read_line(&mut input) { @@ -36,7 +43,7 @@ fn main() { match command { "cd" => { - prompt.pwd = builtins::cd(args); + cwd = builtins::cd(args); previous_command = None; } "exit" => return, @@ -70,7 +77,11 @@ fn main() { if let Some(mut final_command) = previous_command { match final_command.wait() { Ok(ret) => match ret.code() { - Some(code) => println!("exit code [{}]", code), + Some(code) => { + if cfg!(debug_assertions) { + println!("exit code [{}]", code); + } + }, None => println!("Process termed by signal"), }, Err(e) => eprintln!("error waiting on final command: {}", e), |