Merge pull request #5542 from casey/exit-without-flushing

Exit without flushing stdout and stderr
This commit is contained in:
Ed Page 2024-06-21 12:45:51 -05:00 committed by GitHub
commit cf151fd46b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 11 deletions

View file

@ -23,7 +23,7 @@ use crate::output::fmt::Colorizer;
use crate::output::fmt::Stream;
use crate::parser::features::suggestions;
use crate::util::FlatMap;
use crate::util::{color::ColorChoice, safe_exit, SUCCESS_CODE, USAGE_CODE};
use crate::util::{color::ColorChoice, SUCCESS_CODE, USAGE_CODE};
use crate::Command;
#[cfg(feature = "error-context")]
@ -233,7 +233,7 @@ impl<F: ErrorFormatter> Error<F> {
pub fn exit(&self) -> ! {
// Swallow broken pipe errors
let _ = self.print();
safe_exit(self.exit_code())
std::process::exit(self.exit_code());
}
/// Prints formatted and colored error to `stdout` or `stderr` according to its error kind

View file

@ -29,15 +29,6 @@ pub(crate) const SUCCESS_CODE: i32 = 0;
// - Python's `argparse` returns 2
pub(crate) const USAGE_CODE: i32 = 2;
pub(crate) fn safe_exit(code: i32) -> ! {
use std::io::Write;
let _ = std::io::stdout().lock().flush();
let _ = std::io::stderr().lock().flush();
std::process::exit(code)
}
#[cfg(not(feature = "unicode"))]
pub(crate) fn eq_ignore_case(left: &str, right: &str) -> bool {
left.eq_ignore_ascii_case(right)