From c469e3dadc604a9694f6262032b5e8cc89178799 Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Tue, 10 Feb 2026 19:57:51 +0900 Subject: [PATCH] expr --version >/dev/full panics & --help > /dev/full should fail --- src/uu/expr/src/expr.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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());