nushell/crates/nu-cmd-lang/src/core_commands
JT 5b03bca138
Remove autoprinting of loop block values (#8618)
# Description

This removes autoprinting the final value of a loop, much in the same
spirit as not autoprinting values at the end of statements. As we fix
these corner cases, it becomes more consistent that to print to the
screen in a script, you use the `print` command.

This gives a noticeable performance improvement as a bonus.

Before:
```
C:\Source\nushell〉 for x in 1..10 { $x }
1
2
3
4
5
6
7
8
9
10
```
Now:
```
C:\Source\nushell〉 for x in 1..10 { $x }
C:\Source\nushell〉
```

# User-Facing Changes

**BREAKING CHANGE**

Loops like `for`, `loop`, and `while` will no longer automatically print
loop values to the screen.

# 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` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-26 13:23:54 +13:00
..
overlay Revert "Allow NU_LIBS_DIR and friends to be const" (#8501) 2023-03-17 09:33:24 -05:00
alias.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
break_.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
collect.rs Move variables to var stack (#8604) 2023-03-25 12:56:45 +13:00
commandline.rs fix: fix commandline when called with no arguments (#8207) 2023-03-16 17:45:35 -05:00
const_.rs Switch let/let-env family to init with math expressions (#8545) 2023-03-23 09:14:10 +13:00
continue_.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
def_env.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
def.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
describe.rs Cratification: Break out nu_cmd_lang into a separate crate (#8181) 2023-02-24 09:54:42 -06:00
do_.rs Restrict closure expression to be something like {|| ...} (#8290) 2023-03-17 07:36:28 -05:00
echo.rs Cratification: Break out nu_cmd_lang into a separate crate (#8181) 2023-02-24 09:54:42 -06:00
error_make.rs FIX: do not allow *start > end* in error make spans (#8570) 2023-03-23 20:31:06 +01:00
export_alias.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
export_def_env.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
export_def.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
export_extern.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
export_use.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
export.rs Cratification: Break out nu_cmd_lang into a separate crate (#8181) 2023-02-24 09:54:42 -06:00
extern_.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
for_.rs Remove autoprinting of loop block values (#8618) 2023-03-26 13:23:54 +13:00
help_aliases.rs Cratification: Break out nu_cmd_lang into a separate crate (#8181) 2023-02-24 09:54:42 -06:00
help_commands.rs Cratification: Break out nu_cmd_lang into a separate crate (#8181) 2023-02-24 09:54:42 -06:00
help_externs.rs Added help externs command (#8403) 2023-03-15 18:40:27 +01:00
help_modules.rs Document and critically review ShellError variants - Ep. 3 (#8340) 2023-03-06 18:33:09 +01:00
help_operators.rs Cratification: Break out nu_cmd_lang into a separate crate (#8181) 2023-02-24 09:54:42 -06:00
help.rs Document and critically review ShellError variants - Ep. 3 (#8340) 2023-03-06 18:33:09 +01:00
hide_env.rs Document and critically review ShellError variants - Ep. 3 (#8340) 2023-03-06 18:33:09 +01:00
hide.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
if_.rs Switch let/let-env family to init with math expressions (#8545) 2023-03-23 09:14:10 +13:00
ignore.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
let_.rs Switch let/let-env family to init with math expressions (#8545) 2023-03-23 09:14:10 +13:00
loop_.rs Remove autoprinting of loop block values (#8618) 2023-03-26 13:23:54 +13:00
match_.rs Move variables to var stack (#8604) 2023-03-25 12:56:45 +13:00
mod.rs Fix closures that use matches. Move 'collect' to core. (#8596) 2023-03-24 22:50:23 +13:00
module.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
mut_.rs Switch let/let-env family to init with math expressions (#8545) 2023-03-23 09:14:10 +13:00
register.rs Clarify how register works (#8583) 2023-03-23 13:02:22 -05:00
return_.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
try_.rs Restrict closure expression to be something like {|| ...} (#8290) 2023-03-17 07:36:28 -05:00
use_.rs Revert "Allow NU_LIBS_DIR and friends to be const" (#8501) 2023-03-17 09:33:24 -05:00
version.rs Fix the SQLite feature name in version (#8381) 2023-03-09 20:49:29 -08:00
while_.rs Remove autoprinting of loop block values (#8618) 2023-03-26 13:23:54 +13:00