mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 14:59:16 +02:00
Split canonicalize function in two for missing and existing behavior (#1576)
* Split allow missing logic in two functions * Replace use of old canonicalize
This commit is contained in:
committed by
GitHub
parent
57c62de66f
commit
38b2846024
@ -5,7 +5,7 @@ use crate::commands::mkdir::MkdirArgs;
|
||||
use crate::commands::mv::MoveArgs;
|
||||
use crate::commands::rm::RemoveArgs;
|
||||
use crate::data::dir_entry_dict;
|
||||
use crate::path::{canonicalize, normalize, AllowMissing};
|
||||
use crate::path::{canonicalize_existing, normalize};
|
||||
use crate::prelude::*;
|
||||
use crate::shell::completer::NuCompleter;
|
||||
use crate::shell::shell::Shell;
|
||||
@ -188,14 +188,13 @@ impl Shell for FilesystemShell {
|
||||
if target == Path::new("-") {
|
||||
PathBuf::from(&self.last_path)
|
||||
} else {
|
||||
let path =
|
||||
canonicalize(self.path(), target, AllowMissing(false)).map_err(|_| {
|
||||
ShellError::labeled_error(
|
||||
"Cannot change to directory",
|
||||
"directory not found",
|
||||
&v.tag,
|
||||
)
|
||||
})?;
|
||||
let path = canonicalize_existing(self.path(), target).map_err(|_| {
|
||||
ShellError::labeled_error(
|
||||
"Cannot change to directory",
|
||||
"directory not found",
|
||||
&v.tag,
|
||||
)
|
||||
})?;
|
||||
|
||||
if !path.is_dir() {
|
||||
return Err(ShellError::labeled_error(
|
||||
|
Reference in New Issue
Block a user