New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let with pipeline #9589
Let with pipeline #9589
Conversation
So we can now |
I tried |
you should be able to do that yup 😊
this might require some lazy evaluation of commands, right? |
The lazy evaluation semantic is present in closures, i.e. What is a pipeline? I am finding it confusing to think of pipelines as more general than expressions. |
# Description This extends the syntax fix for `let` (#9589) to `mut` as well. Example: `mut x = "hello world" | str length; print $x` closes #9634 # User-Facing Changes `mut` now joins `let` in being able to be assigned from a pipeline # Tests + Formatting <!-- Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect -A clippy::result_large_err` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass - `cargo run -- crates/nu-std/tests/run.nu` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` --> # After Submitting <!-- If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. -->
related to nushell/nushell#9589. because the new syntax is imo better, i propose to remove parentheses in simple `let` variable declarations, e.g. ```nushell let package_file = ($path | path join "package.nuon") ``` becomes ```nushell let package_file = $path | path join "package.nuon" ```
Description
This changes the default behaviour of
let
to be able to take a pipeline as its initial value.For example:
This is a change from the existing behaviour, where the right hand side is assumed to be an expression. Pipelines are more general, and can be more powerful.
My google foo is failing me, but this also fixes this issue:
Currently, this reads
foo
as a bareword that gets converted to a string rather than running thefoo
command. In practice, this is really annoying and is a really hard to spot bug in a script.User-Facing Changes
BREAKING CHANGE BREAKING CHANGE
let
gains the power to be assigned via a pipeline. However, this changes the behaviour oflet x = foo
from assigning the string "foo" to$x
to being "run the commandfoo
and give the result to$x
"Tests + Formatting
After Submitting