mirror of
https://github.com/nushell/nushell
synced 2024-12-28 05:53:09 +00:00
Fix path-related parts of value shell
This commit is contained in:
parent
1d64d90419
commit
570a0ac275
1 changed files with 11 additions and 10 deletions
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue