From c9eb3b90df436eb5bc5131293327c0efd1a28322 Mon Sep 17 00:00:00 2001 From: Justine Date: Mon, 20 Feb 2023 00:16:24 +0100 Subject: [PATCH] Fixed line returns --- README.md | 6 ------ out.txt | 6 ------ src/lib.rs | 12 ++++++------ 3 files changed, 6 insertions(+), 18 deletions(-) delete mode 100644 out.txt diff --git a/README.md b/README.md index 98eec3f..f229f3f 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,6 @@ # Sqish Rust Shell. This is an attempt to create a simple shell in Rust, because why not. -TO DO: -* Implement Alt+z cancels last hotkey (meh), -* rc file shoudl probably just be called .sqishrc, and history .sqishrc.hist -* Typing vim aaa and then up arrow does not work properly ? It seems to get empty history lines -* Have a "Command not found" without having to display the previous return code - ## sqishrc (Config) See the included sqishrc.yaml.example file included, and copy it as ~/.sqishrc.yaml diff --git a/out.txt b/out.txt deleted file mode 100644 index a6d50c4..0000000 --- a/out.txt +++ /dev/null @@ -1,6 +0,0 @@ -Cargo.lock -Cargo.toml -out.txt -README.md -src -target diff --git a/src/lib.rs b/src/lib.rs index 88c6b63..7da051e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -101,7 +101,7 @@ pub mod shell { .spawn() { Ok(h) => h, Err(_) => { - let err_string = format!("Command not found : {}\r\n", command); + let err_string = format!("Not found : {}", command); return String::from(err_string); }, }; @@ -215,19 +215,19 @@ pub mod shell { if conf.aliases.contains_key(mycommand) { *mycommand = conf.aliases[mycommand].clone(); } - if (mycommand != &String::from("\n")) && (mycommand != &String::from("exit")) { + if (mycommand != &String::from("")) && (mycommand != &String::from("exit")) { let comm = replace_signs(&mycommand); RawTerminal::suspend_raw_mode(&stdout); let res = handle_input(&comm); RawTerminal::activate_raw_mode(&stdout); mycommand.clear(); - for line in res.split('\n') { - if line != "\r" { - write!(stdout, "\r\n{}", line); + for line in res.split("\r\n") { + if line != "" && line.starts_with('N'){ + write!(stdout, "{}\r\n", line); } } conf.update_prompt(get_curr_history_number()); - write!(stdout, "\r\n{}", conf.promptline).unwrap(); + write!(stdout, "{}", conf.promptline).unwrap(); stdout.flush(); *current_number += 1; } else if mycommand == &String::from("exit") {