diff --git a/crates/nu-parser/src/parse.rs b/crates/nu-parser/src/parse.rs index 1a8096625..30c657c43 100644 --- a/crates/nu-parser/src/parse.rs +++ b/crates/nu-parser/src/parse.rs @@ -1997,7 +1997,7 @@ fn expand_shorthand_forms( if lite_pipeline.commands[0].parts[0].contains('=') && !lite_pipeline.commands[0].parts[0].starts_with('$') { - let assignment: Vec<_> = lite_pipeline.commands[0].parts[0].split('=').collect(); + let assignment: Vec<_> = lite_pipeline.commands[0].parts[0].splitn(2, '=').collect(); if assignment.len() != 2 { ( lite_pipeline.clone(), diff --git a/tests/shell/environment/env.rs b/tests/shell/environment/env.rs index 75b2f3f1e..960c7c884 100644 --- a/tests/shell/environment/env.rs +++ b/tests/shell/environment/env.rs @@ -14,6 +14,52 @@ fn env_shorthand() { assert_eq!(actual.out, "bar"); } +#[test] +fn env_shorthand_with_equals() { + let actual = nu!(cwd: ".", r#" + RUST_LOG=my_module=info $nu.env.RUST_LOG + "#); + assert_eq!(actual.out, "my_module=info"); +} + +#[test] +fn env_shorthand_with_comma_equals() { + let actual = nu!(cwd: ".", r#" + RUST_LOG=info,my_module=info $nu.env.RUST_LOG + "#); + assert_eq!(actual.out, "info,my_module=info"); +} + +#[test] +fn env_shorthand_with_comma_colons_equals() { + let actual = nu!(cwd: ".", r#" + RUST_LOG=info,my_module=info,lib_crate::lib_mod=trace $nu.env.RUST_LOG + "#); + assert_eq!(actual.out, "info,my_module=info,lib_crate::lib_mod=trace"); +} + +#[test] +fn env_shorthand_multi_second_with_comma_colons_equals() { + let actual = nu!(cwd: ".", r#" + FOO=bar RUST_LOG=info,my_module=info,lib_crate::lib_mod=trace $nu.env.FOO + $nu.env.RUST_LOG + "#); + assert_eq!( + actual.out, + "barinfo,my_module=info,lib_crate::lib_mod=trace" + ); +} + +#[test] +fn env_shorthand_multi_first_with_comma_colons_equals() { + let actual = nu!(cwd: ".", r#" + RUST_LOG=info,my_module=info,lib_crate::lib_mod=trace FOO=bar $nu.env.FOO + $nu.env.RUST_LOG + "#); + assert_eq!( + actual.out, + "barinfo,my_module=info,lib_crate::lib_mod=trace" + ); +} + #[test] fn env_shorthand_multi() { let actual = nu!(cwd: ".", r#"