aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonas Maier <>2026-03-04 18:08:43 +0100
committerJonas Maier <>2026-03-04 18:08:43 +0100
commit9d7a203118204ed71eb56834c9b8fa7709835fc0 (patch)
treef7dbf585ee52f7a460ff8839b4acfa5b5b440fc8 /src
parent9e8d6c77fe768423340beab8ed4ef4e4dd7187df (diff)
downloadpish-9d7a203118204ed71eb56834c9b8fa7709835fc0.tar.gz
no enter spam, proper exit
Diffstat (limited to 'src')
-rw-r--r--src/main.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index cd934d0..53337c8 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -146,7 +146,7 @@ fn run_command(raw: &ScopedRawMode, line: Vec<u8>) {
None => todo!("homedir"),
};
- if let Err(e) = std::env::set_current_dir(target) {
+ if let Err(_) = std::env::set_current_dir(target) {
print!("ERR {PROMPT}");
} else {
print!("{PROMPT}");
@@ -209,9 +209,11 @@ fn main() {
// Enter
b'\r' => {
- print!("\r\n");
let line = line.dump();
- run_command(&raw, line);
+ if !line.is_empty() {
+ print!("\r\n");
+ run_command(&raw, line);
+ }
}
// Backspace (127 on most systems)
@@ -242,7 +244,7 @@ fn main() {
move_cursor(Direction::Left, 1);
line.left();
}
- _ => {}
+ x => todo!("escape character {x}")
}
}
}
@@ -255,4 +257,7 @@ fn main() {
}
}
}
+
+ raw.disable();
+ println!();
}