mirror of
https://github.com/nushell/nushell
synced 2024-12-28 05:53:09 +00:00
nu-command/filesystem: clean whitespaces from paths in cd and open (#5310)
This commit is contained in:
parent
3eb447030b
commit
cd2df83ddc
2 changed files with 6 additions and 2 deletions
|
@ -58,7 +58,10 @@ impl Command for Cd {
|
|||
(cwd.to_string_lossy().to_string(), v.span)
|
||||
}
|
||||
} 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) => {
|
||||
if !p.is_dir() {
|
||||
return Err(ShellError::NotADirectory(v.span));
|
||||
|
|
|
@ -83,7 +83,8 @@ impl Command for Open {
|
|||
}
|
||||
};
|
||||
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) {
|
||||
#[cfg(unix)]
|
||||
|
|
Loading…
Reference in a new issue