avoid freeze for table print (#6688)

* avoid freeze for table print

* make failed_with_proper_exit_code work again

* add test case for table

* fix un-used import on windows
This commit is contained in:
WindSoilder
2022-10-10 20:32:55 +08:00
committed by GitHub
parent 2f1711f783
commit 1998bce19f
4 changed files with 46 additions and 24 deletions

View File

@ -424,7 +424,7 @@ impl PipelineData {
stack: &mut Stack,
no_newline: bool,
to_stderr: bool,
) -> Result<(), ShellError> {
) -> Result<i64, ShellError> {
// If the table function is in the declarations, then we can use it
// to create the table value that will be printed in the terminal
@ -452,10 +452,13 @@ impl PipelineData {
// 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);
}
}
return Ok(());
return Ok(0);
}
match engine_state.find_decl("table".as_bytes(), &[]) {
@ -474,7 +477,7 @@ impl PipelineData {
}
};
Ok(())
Ok(0)
}
fn write_all_and_flush(
@ -483,7 +486,7 @@ impl PipelineData {
config: &Config,
no_newline: bool,
to_stderr: bool,
) -> Result<(), ShellError> {
) -> Result<i64, ShellError> {
for item in self {
let mut out = if let Value::Error { error } = item {
let working_set = StateWorkingSet::new(engine_state);
@ -506,7 +509,7 @@ impl PipelineData {
}
}
Ok(())
Ok(0)
}
}