From: Ian Jackson Date: Tue, 1 Jun 2021 14:37:23 +0000 (+0100) Subject: otter cli: Tiny fixes to stdout handling X-Git-Tag: otter-0.7.0~143 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=24917d794d2915129ae49bb5038c915bc23fe2d2;p=otter.git otter cli: Tiny fixes to stdout handling Signed-off-by: Ian Jackson --- diff --git a/src/bin/otter.rs b/src/bin/otter.rs index dfea6f19..f8310d9c 100644 --- a/src/bin/otter.rs +++ b/src/bin/otter.rs @@ -191,10 +191,7 @@ fn parse_args( exit(match rc { 0 => { if let Some(eh) = extra_help { - eh(&mut stdout).unwrap_or_else(|e|{ - eprintln!("write help to stdout: {:?}", &e); - exit(EXIT_DISASTER); - }); + eh(&mut stdout).unwrap(); } 0 }, @@ -202,6 +199,7 @@ fn parse_args( _ => panic!("unexpected error rc {} from ArgumentParser::parse", rc), }); } + mem::drop(stdout); mem::drop(ap); let completed = completer(parsed) .unwrap_or_else(|e:ArgumentParseError| { diff --git a/src/utils.rs b/src/utils.rs index d4533ef3..9ce62a28 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -735,7 +735,7 @@ pub struct CookedStdout(pub BufWriter>); impl CookedStdout { pub fn new() -> Self { Self(BufWriter::new(RawStdout::new())) } fn handle_err(e: io::Error) -> ! { - AE::from(e).context("write stdout").end_process(12); + AE::from(e).context("write stdout").end_process(EXIT_DISASTER as _); } fn must_flush(&mut self) { self.0.flush().unwrap_or_else(|e| Self::handle_err(e))