Avoid blocking when o+e> redirects too much stderr message#8784
Avoid blocking when o+e> redirects too much stderr message#8784fdncred merged 29 commits intonushell:mainfrom
o+e> redirects too much stderr message#8784Conversation
|
Thank you for this detailed PR description! |
| call: &Call, | ||
| redirect_stdout: bool, | ||
| redirect_stderr: bool, | ||
| out_file: Option<Spanned<String>>, |
There was a problem hiding this comment.
This doesn't feel right to me. create_external_command shouldn't need to know that its output will be going to a file.
|
I'm glad we're trying to fix this issue. I'm not sure if this is quite the right approach. |
Yeah I know about your concern, but I think if we write |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #8784 +/- ##
==========================================
- Coverage 68.96% 68.94% -0.02%
==========================================
Files 641 641
Lines 102434 102540 +106
==========================================
+ Hits 70646 70701 +55
- Misses 31788 31839 +51
|
|
i see you have made quite a few merges @WindSoilder 😮 if it's ready, maybe this PR should land to avoid more conflicts? 😋 |
Ah yeah, I merged from main frequently because I want to have latest main with the fix installed on my machine :-) |
|
Finally I think it's ready to review, it only involves parsing change, and we don't need to change |
|
@WindSoilder glad to see you arrived and a green ci, let's wait until the release and land this early on in the dev cycle so it can get ample testing. thanks! |
|
So...I think it's ready and we can have full test under current version :-) |
|
thanks @WindSoilder. let's give it a try. |
Description
Fixes: #8565
Here is another pr #7240 tried to address the issue, but it works in a wrong way.
After this change
o+e>won't redirect all stdout message then stderr message and it works more like how bash does.User-Facing Changes
For the given python code:
Running
python test.py out+err> a.txtshoudn't hang nushell, anda.txtkeeps output in the same orderAbout the change
The core idea is that when doing lite-parsing, introduce a new variant
LiteElement::SameTargetRedirectionif we meetout+err>redirection token(which is generated by lex function),During converting from lite block to block, LiteElement::SameTargetRedirection will be converted to PipelineElement::SameTargetRedirection.
Then in the block eval process, if we get PipelineElement::SameTargetRedirection, we'll invoke
run-externalwith--redirect-combineflag, then pipe the result into save commandWhat happened internally?
Take the following command as example:
^ls o+e> log.txtlex parsing result(
Tokens) are not changed, butLiteBlockandBlockis changed after this pr.LiteBlock before
LiteBlock after
Block before
Block after
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 -- --checkto check standard code formatting (cargo fmt --allapplies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collectto check that you're using the standard code stylecargo test --workspaceto check that all tests passcargo run -- crates/nu-utils/standard_library/tests.nuto run the tests for the standard libraryAfter Submitting
If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.