nushell/crates/nu-protocol
WindSoilder c371d1a535
fix exit_code handling when running a scripts with ctrlc (#11466)
# Description
Fixes: #11394

When run `^sleep 3` we have an `exit_code ListStream`, and when we press
ctrl-c, this `ListStream` will return None. But it's not expected,
because `exit_code` sender in `run_external` always send an exit code
out.

This pr is trying to fix the issue by introducing a `first_guard` into
ListStream, it will always generate a value from underlying stream if
`first_guard` is true, so it's guarantee to have at least one value to
return.

And the pr also do a little refactor, which makes use of
`ListStream::from_stream` rather than construct it manually.

# User-Facing Changes
## Before
```
> nu -c "^sleep 3"  # press ctrl-c
> echo $env.LAST_EXIT_CODE
0
```

## After
```
> nu -c "^sleep 3"  # press ctrl-c
> echo $env.LAST_EXIT_CODE
255
```

# Tests + Formatting
None, sorry that I don't think it's easy to test the ctrlc behavior.

# After Submitting
None
2024-01-30 22:41:14 +08:00
..
src fix exit_code handling when running a scripts with ctrlc (#11466) 2024-01-30 22:41:14 +08:00
tests Allow plugins to receive configuration from the nushell configuration (#10955) 2024-01-15 16:59:47 +08:00
Cargo.toml Upgrade byte-unit from 4.0 to 5.1 (#11584) 2024-01-21 14:17:28 -06:00
LICENSE Fix rest of license year ranges (#8727) 2023-04-04 09:03:29 +12:00
README.md Add nu-protocol 2021-09-02 13:29:43 +12:00

nu-protocol

The nu-protocol crate holds the definitions of structs/traits that are used throughout Nushell. This gives us one way to expose them to many other crates, as well as make these definitions available to each other, without causing mutually recursive dependencies.