diff --git a/crates/nu-cli/src/commands.rs b/crates/nu-cli/src/commands.rs index 313202e6a..cffbcb0d0 100644 --- a/crates/nu-cli/src/commands.rs +++ b/crates/nu-cli/src/commands.rs @@ -22,7 +22,10 @@ pub fn evaluate_commands( let (block, delta) = { let mut working_set = StateWorkingSet::new(engine_state); - let (input, _) = if commands.item.starts_with('\'') || commands.item.starts_with('"') { + let (input, _) = if commands.item.starts_with('\'') + || commands.item.starts_with('"') + || commands.item.starts_with('`') + { ( trim_quotes(commands.item.as_bytes()), commands.span.start + 1, diff --git a/crates/nu-command/src/system/run_external.rs b/crates/nu-command/src/system/run_external.rs index f34e53892..bbce0d9f4 100644 --- a/crates/nu-command/src/system/run_external.rs +++ b/crates/nu-command/src/system/run_external.rs @@ -512,6 +512,7 @@ fn trim_enclosing_quotes(input: &str) -> String { match (chars.next(), chars.next_back()) { (Some('"'), Some('"')) => chars.collect(), (Some('\''), Some('\'')) => chars.collect(), + (Some('`'), Some('`')) => chars.collect(), _ => input.to_string(), } } diff --git a/src/main.rs b/src/main.rs index e028a5d37..e7bd915a3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -83,13 +83,13 @@ fn main() -> Result<()> { for arg in std::env::args().skip(1) { if !script_name.is_empty() { args_to_script.push(if arg.contains(' ') { - format!("'{}'", arg) + format!("`{}`", arg) } else { arg }); } else if collect_arg_nushell { args_to_nushell.push(if arg.contains(' ') { - format!("'{}'", arg) + format!("`{}`", arg) } else { arg }); diff --git a/tests/shell/pipeline/commands/external.rs b/tests/shell/pipeline/commands/external.rs index 83bb0d73c..4c0257e3e 100644 --- a/tests/shell/pipeline/commands/external.rs +++ b/tests/shell/pipeline/commands/external.rs @@ -297,6 +297,15 @@ mod nu_commands { assert_eq!(actual.out, "foo"); } + + #[test] + fn better_arg_quoting() { + let actual = nu!(cwd: ".", r#" + nu -c "\# '" + "#); + + assert_eq!(actual.out, ""); + } } mod nu_script {