Removed warnings

This commit is contained in:
Justine Pelletreau 2023-02-03 13:37:45 +01:00
parent 1b57352393
commit 28783a5d1b
3 changed files with 6 additions and 10 deletions

View File

@ -4,3 +4,7 @@ Rust Shell. This is an attempt to create a simple shell in Rust, because why not
!!! LOOK into the pty crate to handle pseudoterminals such as in top or ssh
My starting point is [this article](https://www.joshmcguigan.com/blog/build-your-own-shell-rust/) which is excellent. I will start with the final form of a shell given in the article and try to reformat it:
## To fix
* Autocomplete : when nothing found, return input
* Autocomplete : Weird permission issues sometimes (ignore unallowed files and folders)

View File

@ -236,12 +236,6 @@ pub mod shell {
let mut current_pos: usize = 0;
let mut max_pos: usize = 0;
//Used to keep the result of the last autocomplete
//Next time we press tab we get a different result so that we can
//rotate between files in the dir for example
//Resetted by pressing enter
let mut prev_autocomplete = String::new();
//Initialize
write!(stdout, "\r\n SquiShell (sqish)--- \r\n{}", prompt);
stdout.flush();
@ -255,8 +249,7 @@ pub mod shell {
continue;
}
//Search
let (res, list) = autocomplete(&mycommand, &prev_autocomplete);
*&mut prev_autocomplete = String::from(res.as_str());
let (res, list) = autocomplete(&mycommand);
write!(stdout, "\r\n{}\r\n", list);
mycommand.clear();
mycommand.push_str(&res);
@ -267,7 +260,6 @@ pub mod shell {
}
Key::Char('\n') => {
*&mut prev_autocomplete = String::new();
current_number = get_curr_history_number();
prompt = build_prompt(&current_number);
current_pos = 0;

View File

@ -55,7 +55,7 @@ fn autocomplete_file(input: &String) -> std::io::Result<(String, String)> {
if input_searchee.contains('/') {
//Correctly taking first and last part...
let splitted_searchstring = &input_searchee.split('/');
let mut trimmed_searchee = &splitted_searchstring.clone().last().unwrap();
let trimmed_searchee = &splitted_searchstring.clone().last().unwrap();
let splitted_searchstring = &mut input_searchee.clone().split('/').collect::<Vec<&str>>();
splitted_searchstring.pop();
let mut tosearch = splitted_searchstring.join("/");