From 570a0ac275a43b41c253cf1e015ce2ba082648de Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Tue, 27 Aug 2019 17:15:05 +1200 Subject: [PATCH] Fix path-related parts of value shell --- src/shell/value_shell.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/shell/value_shell.rs b/src/shell/value_shell.rs index 3c4e78c8bf..5e1e8c2230 100644 --- a/src/shell/value_shell.rs +++ b/src/shell/value_shell.rs @@ -84,19 +84,20 @@ impl Shell for ValueShell { let path = match args.nth(0) { None => "/".to_string(), Some(v) => { - let target = v.as_string()?; + let target = v.as_path()?; let mut cwd = PathBuf::from(&self.path); - match target { - x if x == ".." => { - cwd.pop(); + + if target == PathBuf::from("..") { + cwd.pop(); + } else { + match target.to_str() { + Some(target) => match target.chars().nth(0) { + Some(x) if x == '/' => cwd = PathBuf::from(target), + _ => cwd.push(target), + }, + None => cwd.push(target), } - _ => match target.chars().nth(0) { - Some(x) if x == '/' => cwd = PathBuf::from(target), - _ => { - cwd.push(target); - } - }, } cwd.to_string_lossy().to_string() }