mirror of
https://github.com/nushell/nushell.git
synced 2025-01-27 16:48:44 +01:00
Fix path-related parts of value shell
This commit is contained in:
parent
1d64d90419
commit
570a0ac275
@ -84,19 +84,20 @@ impl Shell for ValueShell {
|
|||||||
let path = match args.nth(0) {
|
let path = match args.nth(0) {
|
||||||
None => "/".to_string(),
|
None => "/".to_string(),
|
||||||
Some(v) => {
|
Some(v) => {
|
||||||
let target = v.as_string()?;
|
let target = v.as_path()?;
|
||||||
|
|
||||||
let mut cwd = PathBuf::from(&self.path);
|
let mut cwd = PathBuf::from(&self.path);
|
||||||
match target {
|
|
||||||
x if x == ".." => {
|
if target == PathBuf::from("..") {
|
||||||
cwd.pop();
|
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()
|
cwd.to_string_lossy().to_string()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user