diff --git a/crates/nu-parser/src/parse.rs b/crates/nu-parser/src/parse.rs index 6bc3ecfe0..6e18edccf 100644 --- a/crates/nu-parser/src/parse.rs +++ b/crates/nu-parser/src/parse.rs @@ -2130,7 +2130,7 @@ fn parse_definition(call: &LiteCommand, scope: &dyn ParserScope) -> Option Option Op return Some(ParseError::mismatch("definition", call.parts[0].clone())); } - let name = call.parts[1].item.clone(); + let name = trim_quotes(&call.parts[1].item); let (signature, error) = parse_signature(&name, &call.parts[2], scope); if err.is_none() { err = error; diff --git a/tests/shell/pipeline/commands/internal.rs b/tests/shell/pipeline/commands/internal.rs index e9a5f3172..242a1ea1c 100644 --- a/tests/shell/pipeline/commands/internal.rs +++ b/tests/shell/pipeline/commands/internal.rs @@ -368,6 +368,18 @@ fn run_custom_command_with_flag_missing() { assert_eq!(actual.out, "empty"); } +#[test] +fn run_custom_subcommand() { + let actual = nu!( + cwd: ".", + r#" + def "str double" [x] { echo $x $x | str collect }; str double bob + "# + ); + + assert_eq!(actual.out, "bobbob"); +} + #[test] fn set_variable() { let actual = nu!(