diff --git a/src/uu/false/src/false.rs b/src/uu/false/src/false.rs index 097e01de3b6..0fc90364a90 100644 --- a/src/uu/false/src/false.rs +++ b/src/uu/false/src/false.rs @@ -4,23 +4,14 @@ // file that was distributed with this source code. use clap::{Arg, ArgAction, Command}; use std::{ffi::OsString, io::Write}; -use uucore::error::{UResult, set_exit_code}; - use uucore::translate; -#[uucore::main(no_signals)] -// TODO: modify proc macro to allow no-result uumain -#[expect(clippy::unnecessary_wraps, reason = "proc macro requires UResult")] -pub fn uumain(args: impl uucore::Args) -> UResult<()> { - // Mirror GNU options, always return `1`. In particular even the 'successful' cases of no-op, - // and the interrupted display of help and version should return `1`. Also, we return Ok in all - // paths to avoid the allocation of an error object, an operation that could, in theory, fail - // and unwind through the standard library allocation handling machinery. - set_exit_code(1); - +// uucore::main does not support no-result +// also remove SIGPIPE overhead +pub fn uumain(args: impl uucore::Args) -> i32 { let args: Vec = args.collect(); if args.len() != 2 { - return Ok(()); + return 1; } // args[0] is the name of the binary. @@ -29,14 +20,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } else if args[1] == "--version" { write!(std::io::stdout(), "{}", uu_app().render_version()) } else { - Ok(()) + return 1; }; if let Err(print_fail) = error { let _ = writeln!(std::io::stderr(), "{}: {print_fail}", uucore::util_name()); } - - Ok(()) + 1 } pub fn uu_app() -> Command { diff --git a/src/uu/true/src/true.rs b/src/uu/true/src/true.rs index 7a4da181026..626073c2191 100644 --- a/src/uu/true/src/true.rs +++ b/src/uu/true/src/true.rs @@ -4,17 +4,14 @@ // file that was distributed with this source code. use clap::{Arg, ArgAction, Command}; use std::{ffi::OsString, io::Write}; -use uucore::error::{UResult, set_exit_code}; - use uucore::translate; -#[uucore::main(no_signals)] -// TODO: modify proc macro to allow no-result uumain -#[expect(clippy::unnecessary_wraps, reason = "proc macro requires UResult")] -pub fn uumain(args: impl uucore::Args) -> UResult<()> { +// uucore::main does not support no-result +// also remove SIGPIPE overhead +pub fn uumain(args: impl uucore::Args) -> i32 { let args: Vec = args.collect(); if args.len() != 2 { - return Ok(()); + return 0; } // args[0] is the name of the binary. @@ -23,7 +20,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } else if args[1] == "--version" { write!(std::io::stdout(), "{}", uu_app().render_version()) } else { - Ok(()) + return 0; }; if let Err(print_fail) = error { @@ -32,10 +29,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { // Mirror GNU options. When failing to print warnings or version flags, then we exit // with FAIL. This avoids allocation some error information which may result in yet // other types of failure. - set_exit_code(1); + return 1; } - - Ok(()) + 0 } pub fn uu_app() -> Command {