From 7532991544d7bfc5c663a294d09b0b719ad85fc4 Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Sat, 15 Oct 2022 10:37:31 +1300 Subject: [PATCH] Allow auto-cd to work with backticks (#6728) --- crates/nu-cli/src/repl.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/nu-cli/src/repl.rs b/crates/nu-cli/src/repl.rs index 744fb7aa8c..0b9b99b91f 100644 --- a/crates/nu-cli/src/repl.rs +++ b/crates/nu-cli/src/repl.rs @@ -11,7 +11,7 @@ use log::{info, trace, warn}; use miette::{IntoDiagnostic, Result}; use nu_color_config::get_color_config; use nu_engine::{convert_env_values, eval_block}; -use nu_parser::{lex, parse}; +use nu_parser::{lex, parse, trim_quotes_str}; use nu_protocol::{ ast::PathMember, engine::{EngineState, ReplOperation, Stack, StateWorkingSet}, @@ -380,9 +380,13 @@ pub fn evaluate_repl( let tokens = lex(s.as_bytes(), 0, &[], &[], false); // Check if this is a single call to a directory, if so auto-cd let cwd = nu_engine::env::current_dir_str(engine_state, stack)?; - let path = nu_path::expand_path_with(&s, &cwd); - let orig = s.clone(); + let mut orig = s.clone(); + if orig.starts_with('`') { + orig = trim_quotes_str(&orig).to_string() + } + + let path = nu_path::expand_path_with(&orig, &cwd); if looks_like_path(&orig) && path.is_dir() && tokens.0.len() == 1 { // We have an auto-cd