From 19caef260d0a18b226a32f7a76976d38503f964a Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Tue, 8 Feb 2022 11:21:17 -0500 Subject: [PATCH] Fix 'enter' to expand path before checking for it (#4370) --- crates/nu-command/src/shells/enter.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/nu-command/src/shells/enter.rs b/crates/nu-command/src/shells/enter.rs index 2a586c7104..3ec45ce736 100644 --- a/crates/nu-command/src/shells/enter.rs +++ b/crates/nu-command/src/shells/enter.rs @@ -37,6 +37,10 @@ impl Command for Enter { let path_span = new_path.span()?; let new_path = new_path.as_path()?; + + let cwd = current_dir(engine_state, stack)?; + let new_path = nu_path::canonicalize_with(new_path, &cwd)?; + if !new_path.exists() { return Err(ShellError::DirectoryNotFound(path_span)); } @@ -48,9 +52,6 @@ impl Command for Enter { )); } - let cwd = current_dir(engine_state, stack)?; - let new_path = nu_path::canonicalize_with(new_path, &cwd)?; - let new_path = Value::String { val: new_path.to_string_lossy().to_string(), span: call.head,