forked from extern/nushell
nu-command/filesystem: clean whitespaces from paths in cd and open (#5310)
This commit is contained in:
parent
3eb447030b
commit
cd2df83ddc
@ -58,7 +58,10 @@ impl Command for Cd {
|
|||||||
(cwd.to_string_lossy().to_string(), v.span)
|
(cwd.to_string_lossy().to_string(), v.span)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let path = match nu_path::canonicalize_with(&v.item, &cwd) {
|
let path_no_whitespace =
|
||||||
|
&v.item.trim_end_matches(|x| matches!(x, '\x09'..='\x0d'));
|
||||||
|
|
||||||
|
let path = match nu_path::canonicalize_with(path_no_whitespace, &cwd) {
|
||||||
Ok(p) => {
|
Ok(p) => {
|
||||||
if !p.is_dir() {
|
if !p.is_dir() {
|
||||||
return Err(ShellError::NotADirectory(v.span));
|
return Err(ShellError::NotADirectory(v.span));
|
||||||
|
@ -83,7 +83,8 @@ impl Command for Open {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let arg_span = path.span;
|
let arg_span = path.span;
|
||||||
let path = Path::new(&path.item);
|
let path_no_whitespace = &path.item.trim_end_matches(|x| matches!(x, '\x09'..='\x0d'));
|
||||||
|
let path = Path::new(path_no_whitespace);
|
||||||
|
|
||||||
if permission_denied(&path) {
|
if permission_denied(&path) {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
|
Loading…
Reference in New Issue
Block a user