Skip to content

Commit 2a2e10a

Browse files
committed
expr: exit 3 on write failure for --help/--version
1 parent 4c5b665 commit 2a2e10a

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/uu/expr/src/expr.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,20 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
109109
.collect::<Result<Vec<_>, _>>()?;
110110

111111
if args.len() == 1 && args[0] == b"--help" {
112-
uu_app().print_help()?;
112+
if uu_app().print_help().is_err() {
113+
std::process::exit(3);
114+
}
113115
} else if args.len() == 1 && args[0] == b"--version" {
114-
writeln!(stdout(), "expr {}", uucore::crate_version!())?;
116+
if writeln!(
117+
stdout(),
118+
"{} {}",
119+
uucore::util_name(),
120+
uucore::crate_version!()
121+
)
122+
.is_err()
123+
{
124+
std::process::exit(3);
125+
}
115126
} else {
116127
// The first argument may be "--" and should be be ignored.
117128
let args = if !args.is_empty() && args[0] == b"--" {

0 commit comments

Comments
 (0)