Fixes how environment is cloned inside tight loops (#678)

* Improve cd IO error

* Fix environment cloning in loops

* Remove debug print

* Fmt
This commit is contained in:
Jakub Žádník
2022-01-06 00:21:26 +02:00
committed by GitHub
parent 14cd798f00
commit d0c280f6cc
4 changed files with 19 additions and 11 deletions

View File

@ -34,11 +34,15 @@ impl Command for Cd {
let (path, span) = match path_val {
Some(v) => {
let path = v.as_path()?;
if !path.exists() {
return Err(ShellError::DirectoryNotFound(v.span()?));
}
let path = nu_path::canonicalize_with(path, &cwd)?;
let path = match nu_path::canonicalize_with(path, &cwd) {
Ok(p) => p,
Err(e) => {
return Err(ShellError::DirectoryNotFoundHelp(
v.span()?,
format!("IO Error: {:?}", e),
))
}
};
(path.to_string_lossy().to_string(), v.span()?)
}
None => {