mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 06:55:36 +02:00
Fix cd-ing into a file (#831)
* Add custom error for path not being a directory * Fix cd issue with cd-ing into a file * Keep formatting style as before * Check if path is not a directory and return error if that's the case
This commit is contained in:
committed by
GitHub
parent
be0d221d56
commit
4e171203cc
@ -61,7 +61,13 @@ impl Command for Cd {
|
||||
Some(v) => {
|
||||
let path = v.as_path()?;
|
||||
let path = match nu_path::canonicalize_with(path, &cwd) {
|
||||
Ok(p) => p,
|
||||
Ok(p) => {
|
||||
if !p.is_dir() {
|
||||
return Err(ShellError::NotADirectory(v.span()?));
|
||||
}
|
||||
p
|
||||
}
|
||||
|
||||
Err(e) => {
|
||||
return Err(ShellError::DirectoryNotFoundHelp(
|
||||
v.span()?,
|
||||
|
Reference in New Issue
Block a user