mirror of
https://github.com/nushell/nushell.git
synced 2025-01-22 14:18:55 +01:00
Fix broken ordering of args when parsing command with env vars. (#1841)
This commit is contained in:
parent
8a99d112fc
commit
005d76cf57
@ -19,3 +19,13 @@ fn with_env_shorthand() {
|
|||||||
|
|
||||||
assert_eq!(actual.out, "BARRRR");
|
assert_eq!(actual.out, "BARRRR");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn shorthand_doesnt_reorder_arguments() {
|
||||||
|
let actual = nu!(
|
||||||
|
cwd: "tests/fixtures/formats",
|
||||||
|
"FOO=BARRRR nu --testbin cococo first second"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(actual.out, "firstsecond");
|
||||||
|
}
|
||||||
|
@ -1368,7 +1368,7 @@ fn expand_shorthand_forms(
|
|||||||
if !lite_pipeline.commands[0].args.is_empty() {
|
if !lite_pipeline.commands[0].args.is_empty() {
|
||||||
let new_lite_command_name = lite_pipeline.commands[0].args[0].clone();
|
let new_lite_command_name = lite_pipeline.commands[0].args[0].clone();
|
||||||
let mut new_lite_command_args = lite_pipeline.commands[0].args.clone();
|
let mut new_lite_command_args = lite_pipeline.commands[0].args.clone();
|
||||||
new_lite_command_args.swap_remove(0);
|
new_lite_command_args.remove(0);
|
||||||
|
|
||||||
lite_pipeline.commands[0].name = new_lite_command_name;
|
lite_pipeline.commands[0].name = new_lite_command_name;
|
||||||
lite_pipeline.commands[0].args = new_lite_command_args;
|
lite_pipeline.commands[0].args = new_lite_command_args;
|
||||||
|
@ -55,6 +55,12 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
.help("the nu script to run")
|
.help("the nu script to run")
|
||||||
.index(1),
|
.index(1),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("args")
|
||||||
|
.help("positional args (used by --testbin)")
|
||||||
|
.index(2)
|
||||||
|
.multiple(true),
|
||||||
|
)
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
if let Some(bin) = matches.value_of("testbin") {
|
if let Some(bin) = matches.value_of("testbin") {
|
||||||
|
Loading…
Reference in New Issue
Block a user