Merge pull request #260 from jonathandturner/canon_set_path

Fix the canonicalize of set_path
This commit is contained in:
Jonathan Turner 2019-08-08 13:11:23 +12:00 committed by GitHub
commit 6d4334e0b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -181,8 +181,18 @@ impl Shell for FilesystemShell {
} }
fn set_path(&mut self, path: String) { fn set_path(&mut self, path: String) {
let pathbuf = PathBuf::from(&path);
let path = match dunce::canonicalize(pathbuf.as_path()) {
Ok(path) => {
let _ = std::env::set_current_dir(&path); let _ = std::env::set_current_dir(&path);
self.path = path.clone(); path
}
_ => {
// TODO: handle the case where the path cannot be canonicalized
pathbuf
}
};
self.path = path.to_string_lossy().to_string();
} }
} }