From 20692d581a9cd7574e1e3c78e0d9d63f4ec3678a Mon Sep 17 00:00:00 2001 From: emma Date: Sun, 14 Jul 2024 14:15:55 -0600 Subject: [PATCH] mm(1): makes -e block inferring stdout as an output, mm.1: reflects changes to -e --- docs/mm.1 | 4 +++- src/mm.rs | 13 ++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/mm.1 b/docs/mm.1 index d4659d2..9e26420 100644 --- a/docs/mm.1 +++ b/docs/mm.1 @@ -33,7 +33,9 @@ Opens a path as an input. If one or more of the input files is \(lq-\(rq or if no inputs are specified, the standard input shall be used. .IP \fB-o\fP\ \fIoutput\fP Opens a path as an output. If one or more of the output files is \(lq-\(rq or if -no outputs are specified, the standard output shall be used. +no outputs are specified and the +.B -e +option is not specified, the standard output shall be used. .\" .SH DIAGNOSTICS diff --git a/src/mm.rs b/src/mm.rs index d00dfc2..df431db 100644 --- a/src/mm.rs +++ b/src/mm.rs @@ -68,7 +68,7 @@ fn main() -> ExitCode { if ins.is_empty() { ins.push("-".to_string()); } /* use stdout if no outputs are specified */ - if outs.is_empty() { outs.push("-".to_string()); } + if outs.is_empty() && !e { outs.push("-".to_string()); } /* map all path strings to files */ let inputs = ins.iter().map(|file| { @@ -142,10 +142,13 @@ fn main() -> ExitCode { eprintln!("{}: {}", argv[0], e.strerror()); return ExitCode::from(EX_IOERR as u8); } - /* immediately flush the output for -u */ - if let Err(e) = out.flush() { - eprintln!("{}: {}", argv[0], e.strerror()); - return ExitCode::from(EX_IOERR as u8); + + if u { + /* immediately flush the output for -u */ + if let Err(e) = out.flush() { + eprintln!("{}: {}", argv[0], e.strerror()); + return ExitCode::from(EX_IOERR as u8); + } } } }