diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/commands/change_directory.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/commands/change_directory.rs b/src/commands/change_directory.rs index 2327466..23ebfc6 100644 --- a/src/commands/change_directory.rs +++ b/src/commands/change_directory.rs @@ -12,10 +12,15 @@ pub fn cd(path: &path::Path, context: &mut AppContext) -> std::io::Result<()> { Ok(()) } -pub fn change_directory(context: &mut AppContext, path: &path::Path) -> JoshutoResult { +pub fn change_directory(context: &mut AppContext, mut path: &path::Path) -> JoshutoResult { let new_cwd = if path.is_absolute() { path.to_path_buf() } else { + while let Ok(p) = path.strip_prefix("../") { + parent_directory(context)?; + path = p; + } + let mut new_cwd = std::env::current_dir()?; new_cwd.push(path); new_cwd |