Skip to content
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

When using redirection, if a command generates non-zero exit code, the script should stop running #11191

Merged
merged 3 commits into from
Nov 30, 2023

Conversation

WindSoilder
Copy link
Collaborator

Description

Fixes: #11153

To make sure scripts stop from running on non-zero exit code, we need to invoke might_consume_external_result on PipelineData::ExternalStream, so it can tell nushell if this command exists with non-zero exit code.

And this pr also adjusts some test cases.

User-Facing Changes

^false out> /dev/null; print "ok"

After this pr, it shouldn't print ok.

Tests + Formatting

Done

Copy link
Member

@amtoine amtoine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the changes look simple, the tests good and i was able to reproduce the new expected behaviour...
thanks again @WindSoilder for working on this 🙏

let's land that and have better redirection 👌

@amtoine amtoine merged commit 80881c7 into nushell:main Nov 30, 2023
19 checks passed
hardfau1t pushed a commit to hardfau1t/nushell that referenced this pull request Dec 14, 2023
…e script should stop running (nushell#11191)

# Description
Fixes: nushell#11153

To make sure scripts stop from running on non-zero exit code, we need to
invoke `might_consume_external_result` on
`PipelineData::ExternalStream`, so it can tell nushell if this command
exists with non-zero exit code.

And this pr also adjusts some test cases.

# User-Facing Changes
```nushell
^false out> /dev/null; print "ok"
```

After this pr, it shouldn't print ok.

# Tests + Formatting
Done
dmatos2012 pushed a commit to dmatos2012/nushell that referenced this pull request Feb 20, 2024
…e script should stop running (nushell#11191)

# Description
Fixes: nushell#11153

To make sure scripts stop from running on non-zero exit code, we need to
invoke `might_consume_external_result` on
`PipelineData::ExternalStream`, so it can tell nushell if this command
exists with non-zero exit code.

And this pr also adjusts some test cases.

# User-Facing Changes
```nushell
^false out> /dev/null; print "ok"
```

After this pr, it shouldn't print ok.

# Tests + Formatting
Done
@WindSoilder WindSoilder deleted the redirection_with_error_stop_running branch February 27, 2024 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

output redirection breaks error handling in scripts
2 participants