mirror of
https://github.com/nushell/nushell
synced 2025-01-15 06:34:15 +00:00
Fix the canonicalize of set_path
This commit is contained in:
parent
5c5d5fa983
commit
e8ae46ddb5
1 changed files with 12 additions and 2 deletions
|
@ -181,8 +181,18 @@ impl Shell for FilesystemShell {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_path(&mut self, path: String) {
|
fn set_path(&mut self, path: String) {
|
||||||
let _ = std::env::set_current_dir(&path);
|
let pathbuf = PathBuf::from(&path);
|
||||||
self.path = path.clone();
|
let path = match dunce::canonicalize(pathbuf.as_path()) {
|
||||||
|
Ok(path) => {
|
||||||
|
let _ = std::env::set_current_dir(&path);
|
||||||
|
path
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
// TODO: handle the case where the path cannot be canonicalized
|
||||||
|
pathbuf
|
||||||
|
}
|
||||||
|
};
|
||||||
|
self.path = path.to_string_lossy().to_string();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue