pwd builting and pwd variable fix

This commit is contained in:
g1n 2021-07-21 15:01:26 +00:00
parent 53fad8431c
commit c967591855
1 changed files with 1 additions and 2 deletions

View File

@ -64,15 +64,14 @@ fn main(){
println!();
},
"cd" => {
// default to '/' as new directory if one was not provided
let new_dir = args.peekable().peek().map_or(home_dir.clone(), |x| (*x).to_string());
let root = Path::new(&new_dir);
pwd=root.clone().to_path_buf();
if let Err(e) = env::set_current_dir(&root) {
eprintln!("{}", e);
}
previous_command = None;
pwd=env::current_dir().unwrap();
},
"pwd" => {
println!("{}", pwd.display());