Fix 'enter' to expand path before checking for it (#4370)

This commit is contained in:
JT 2022-02-08 11:21:17 -05:00 committed by GitHub
parent 565be6aaef
commit 19caef260d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,6 +37,10 @@ impl Command for Enter {
let path_span = new_path.span()?; let path_span = new_path.span()?;
let new_path = new_path.as_path()?; 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() { if !new_path.exists() {
return Err(ShellError::DirectoryNotFound(path_span)); 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 { let new_path = Value::String {
val: new_path.to_string_lossy().to_string(), val: new_path.to_string_lossy().to_string(),
span: call.head, span: call.head,