mirror of
https://github.com/nushell/nushell
synced 2025-01-14 22:24:54 +00:00
parent
5f550a355b
commit
52d69bb021
2 changed files with 20 additions and 0 deletions
|
@ -137,6 +137,13 @@ impl WholeStreamCommand for Arc<Block> {
|
||||||
UntaggedValue::Table(elements).into_value(Span::new(start, end)),
|
UntaggedValue::Table(elements).into_value(Span::new(start, end)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} else if block.params.rest_positional.is_some() {
|
||||||
|
//If there is a rest arg, but no args were provided,
|
||||||
|
//we have to set $rest to an empty table
|
||||||
|
ctx.scope.add_var(
|
||||||
|
"$rest",
|
||||||
|
UntaggedValue::Table(Vec::new()).into_value(Span::new(0, 0)),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if let Some(args) = evaluated.args.named {
|
if let Some(args) = evaluated.args.named {
|
||||||
for named in &block.params.named {
|
for named in &block.params.named {
|
||||||
|
|
|
@ -278,6 +278,19 @@ fn run_custom_command_with_rest_and_flag() {
|
||||||
assert_eq!(actual.out, r#"["world","hello","yay"]"#);
|
assert_eq!(actual.out, r#"["world","hello","yay"]"#);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn run_custom_command_with_empty_rest() {
|
||||||
|
let actual = nu!(
|
||||||
|
cwd: ".",
|
||||||
|
r#"
|
||||||
|
def rest-me-with-empty-rest [...rest: string] { echo $rest }; rest-me-with-empty-rest
|
||||||
|
"#
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(actual.out, r#""#);
|
||||||
|
assert_eq!(actual.err, r#""#);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn set_variable() {
|
fn set_variable() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
|
|
Loading…
Reference in a new issue