diff --git a/src/uu/expr/src/expr.rs b/src/uu/expr/src/expr.rs index 75ce8620d6f..caaa9eec9b1 100644 --- a/src/uu/expr/src/expr.rs +++ b/src/uu/expr/src/expr.rs @@ -4,7 +4,7 @@ // file that was distributed with this source code. use clap::{Arg, ArgAction, Command}; -use std::io::Write; +use std::io::{Write, stdout}; use syntax_tree::{AstNode, is_truthy}; use thiserror::Error; use uucore::os_string_to_vec; @@ -109,9 +109,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .collect::, _>>()?; if args.len() == 1 && args[0] == b"--help" { - let _ = uu_app().print_help(); + uu_app().print_help()?; } else if args.len() == 1 && args[0] == b"--version" { - println!("{} {}", uucore::util_name(), uucore::crate_version!()); + writeln!( + stdout(), + "{} {}", + uucore::util_name(), + uucore::crate_version!() + )?; } else { // The first argument may be "--" and should be be ignored. let args = if !args.is_empty() && args[0] == b"--" { @@ -121,8 +126,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { }; let res = AstNode::parse(args)?.eval()?.eval_as_string(); - let _ = std::io::stdout().write_all(&res); - let _ = std::io::stdout().write_all(b"\n"); + let _ = stdout().write_all(&res); + let _ = stdout().write_all(b"\n"); if !is_truthy(&res.into()) { return Err(1.into());