From b1e25166433ce93403324a96f129712e4fac944d Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 11 Oct 2020 18:37:39 +0300 Subject: Properly read username and hostname username is read by using libc::getuid, and checking /etc/passwd for the uid and getting the username from there hostname is read from /proc/sys/kernel/hostname --- src/main.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 0581b13..403fd33 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,10 +7,13 @@ mod prompt; fn main() { match std::fs::read_to_string("/etc/motd") { Ok(motd) => println!("{}", motd), - Err(_) => {}, + Err(_) => {} } - let prompt = prompt::Prompt::new(); + 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), @@ -81,7 +84,7 @@ fn main() { if cfg!(debug_assertions) { println!("exit code [{}]", code); } - }, + } None => println!("Process termed by signal"), }, Err(e) => eprintln!("error waiting on final command: {}", e), -- cgit v1.2.1