From e8ae46ddb5e543396ecf82b6d46def146c893bf5 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Thu, 8 Aug 2019 12:52:29 +1200 Subject: [PATCH] Fix the canonicalize of set_path --- src/shell/filesystem_shell.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/shell/filesystem_shell.rs b/src/shell/filesystem_shell.rs index fab9275dd..5b473f6b5 100644 --- a/src/shell/filesystem_shell.rs +++ b/src/shell/filesystem_shell.rs @@ -181,8 +181,18 @@ impl Shell for FilesystemShell { } fn set_path(&mut self, path: String) { - let _ = std::env::set_current_dir(&path); - self.path = path.clone(); + let pathbuf = PathBuf::from(&path); + 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(); } }