mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 11:45:50 +02:00
Make timeit
take only closures as an argument (#14483)
# Description Fixes #14401 where expressions passed to `timeit` will execute twice. This PR removes the expression support for `timeit`, as this behavior is almost exclusive to `timeit` and can hinder migration to the IR evaluator in the future. Additionally, `timeit` used to be able to take a `block` as an argument. Blocks should probably only be allowed for parser keywords, so this PR changes `timeit` to instead only take closures as an argument. This also fixes an issue where environment updates inside the `timeit` block would affect the parent scope and all commands later in the pipeline. ```nu > timeit { $env.FOO = 'bar' }; print $env.FOO bar ``` # User-Facing Changes `timeit` now only takes a closure as the first argument. # After Submitting Update examples in the book/docs if necessary.
This commit is contained in:
@ -2,7 +2,7 @@ use nu_test_support::nu;
|
||||
|
||||
#[test]
|
||||
fn timeit_show_stdout() {
|
||||
let actual = nu!("let t = timeit nu --testbin cococo abcdefg");
|
||||
let actual = nu!("let t = timeit { nu --testbin cococo abcdefg }");
|
||||
assert_eq!(actual.out, "abcdefg");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user