Stream lazy default output (#15955)

It was brought up in the Discord that `default { open -r foo.txt }`
results in a string instead of streaming output. This changes `default`
such that closures now stream when given simple input.

# Description
If the value isn't expected to be cached, `default` just runs the
closure without caching the value, which allows its output to be
streamed

# User-Facing Changes


# Tests + Formatting
👍 

# After Submitting
This commit is contained in:
Firegem
2025-06-24 19:17:33 -04:00
committed by GitHub
parent a6b8e2f95c
commit cb7ac9199d
2 changed files with 16 additions and 4 deletions

View File

@ -244,3 +244,9 @@ fn return_closure_value() {
let actual = nu!(r#"null | default { {||} }"#);
assert!(actual.out.starts_with("closure"));
}
#[test]
fn lazy_output_streams() {
let actual = nu!(r#"default { nu --testbin cococo 'hello' } | describe"#);
assert!(actual.out.contains("byte stream"));
}