Fixed line returns

This commit is contained in:
Justine 2023-02-20 00:16:24 +01:00
parent ed5d405649
commit c9eb3b90df
3 changed files with 6 additions and 18 deletions

View File

@ -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

View File

@ -1,6 +0,0 @@
Cargo.lock
Cargo.toml
out.txt
README.md
src
target

View File

@ -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") {