Repository navigation
avoid freeze for table print - #6688
Conversation
|
Will this still capture all exit codes like it did before? I like your idea but I don't want to misreport exit codes either. I haven't test yet because I'm on my phone. |
I think so :-), it just move the logic from if let PipelineData::ExternalStream { exit_code, .. } = &mut pipeline_data {
if let Some(exit_code) = exit_code.take().and_then(|it| it.last()) {
stack.add_env_var("LAST_EXIT_CODE".to_string(), exit_code);
} else {
set_last_exit_code(stack, 0);
}
} else {
set_last_exit_code(stack, 0);
}to // Make sure everything has finished
if let Some(exit_code) = exit_code {
let _: Vec<_> = exit_code.into_iter().collect();
let mut exit_codes: Vec<_> = exit_code.into_iter().collect();
if let Some(Value::Int { val, .. }) = exit_codes.pop() {
return Ok(val);
}
} |
|
How can we write tests for this? |
|
nushell/tests/shell/pipeline/commands/external.rs Lines 316 to 327 in 118033e Actually we have one test cover about this, but because of semicolon rule, the test is ignored for now. I'll try to figure out if we can make it works again |
|
Ok, I've updated relative test to make sure that it doesn't break exit code handling; And add one more test case to cover the change. |
|
thanks! let's see if this makes things a little better. |
Description
Fixes: #6594 #6679
As @nibon7 point out, nushell is freeze because blocking channel sender is full, and exit code doesn't send through channel yet.
And while printing out pipeline, it tried to catch
exit_codefirst, so everything hangged on.This pr is going to solve this by removing exit_code consume logic from
eval_blockfunction, and so makepipeline_data.printmethod always consume stdout, then exit_codeFor stderr relative example on #5625 (comment), I'm trying to apply the same consuming logic, but it doesn't work, I need to think how to handle it properly.
Tests
Make sure you've done the following:
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 --features=extra -- -D warnings -D clippy::unwrap_used -A clippy::needless_collectto check that you're using the standard code stylecargo test --workspace --features=extrato check that all the tests pass