Describe the bug
Hi.
Firstly, thank you for making nushell, it's my daily shell for half a year now and I love it.
Over last few days I've been trying to complete a mini-project and I've decided to use nushell for it. I hit some obstacles, which I hereby document. I hope this helps develop nushell further!
I've noticed that documentation of break (and probably continue) is somewhat misleading.
break for core
Break a loop.
Signature
Input/output types:
| input |
output |
| nothing |
nothing |
Examples
Break out of a loop
The language "break out of a loop" together with an example strongly suggests that this is only relevant for loop operation, while in fact it's also relevant for while (pun intended).
As a surprising discovery, it seems to work in each too, but in a very weird way. Even weirder is par-each, as it executes executes all operations only to return error afterwards.
How to reproduce
> seq 1 10 | each { print $in; break }
1
╭────────────╮
│ empty list │
╰────────────╯2
> seq 1 10 | par-each --threads 1 { print $in; break }
2
3
4
5
6
7
8
9
10
Error: nu::shell::eval_block_with_input
× Eval block failed with pipeline input
╭─[entry #25:1:1]
1 │ seq 1 10 | par-each -t 1 { print $in; break }
· ─┬─
· ╰── source value
╰────
Error: × Break used outside of loop
╭─[entry #25:1:1]
1 │ seq 1 10 | par-each -t 1 { print $in; break }
· ──┬──
· ╰── used outside of loop
╰────
Expected behavior
- documentation to clearly mention both
loop and while
break inside of each raises an error, possibly consistently with par-each
Screenshots
No response
Configuration
| key |
value |
| version |
0.88.1 |
| branch |
|
| commit_hash |
|
| build_os |
macos-aarch64 |
| build_target |
aarch64-apple-darwin |
| rust_version |
rustc 1.74.0 (79e9716c9 2023-11-13) (Homebrew) |
| cargo_version |
cargo 1.74.0 |
| build_time |
2023-12-14 17:14:47 +00:00 |
| build_rust_channel |
release |
| allocator |
mimalloc |
| features |
dataframe, default, sqlite, trash, which, zip |
| installed_plugins |
custom-value generate, custom-value generate2, custom-value update, from eml, from ics, from ini, from vcf, gstat, inc, nu-example-1, nu-example-2, nu-example-3, query, query json, query web, query xml |
Additional context
No response
Describe the bug
Hi.
Firstly, thank you for making nushell, it's my daily shell for half a year now and I love it.
Over last few days I've been trying to complete a mini-project and I've decided to use nushell for it. I hit some obstacles, which I hereby document. I hope this helps develop nushell further!
I've noticed that documentation of
break(and probablycontinue) is somewhat misleading.The language "break out of a loop" together with an example strongly suggests that this is only relevant for
loopoperation, while in fact it's also relevant forwhile(pun intended).As a surprising discovery, it seems to work in
eachtoo, but in a very weird way. Even weirder ispar-each, as it executes executes all operations only to return error afterwards.How to reproduce
Expected behavior
loopandwhilebreakinside ofeachraises an error, possibly consistently withpar-eachScreenshots
No response
Configuration
Additional context
No response