aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs26
-rw-r--r--src/prompt.rs2
-rw-r--r--src/user.rs1
3 files changed, 16 insertions, 13 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
+
}
diff --git a/src/prompt.rs b/src/prompt.rs
index 40c96cc..acb11e4 100644
--- a/src/prompt.rs
+++ b/src/prompt.rs
@@ -14,7 +14,7 @@ impl Prompt {
let hostname = user::hostname()?;
let ready = if username == "root" { "#" } else { "$" }.to_owned();
- let ps1 = match std::env::var("PS1") {
+ let ps1 = match std::env::var("PRMOPT") {
Ok(val) => val,
Err(_) => String::from(" {USER}@{HOST} [{PWD}]\n{$} "),
}
diff --git a/src/user.rs b/src/user.rs
index fedf12b..9744928 100644
--- a/src/user.rs
+++ b/src/user.rs
@@ -46,4 +46,3 @@ fn test_username() {
};
assert_eq!(username__, username().unwrap());
}
-