Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/uu/arch/src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::io::{Write, stdout};
use uucore::error::{UResult, USimpleError};
use uucore::translate;

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
uucore::clap_localization::handle_clap_result(uu_app(), args)?;

Expand Down
2 changes: 1 addition & 1 deletion src/uu/basename/src/basename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub mod options {
pub static ZERO: &str = "zero";
}

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
//
// Argument parsing
Expand Down
2 changes: 1 addition & 1 deletion src/uu/dircolors/src/dircolors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fn generate_ls_colors(fmt: &OutputFmt, sep: &str) -> String {
}
}

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;

Expand Down
2 changes: 1 addition & 1 deletion src/uu/dirname/src/dirname.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fn dirname_string_manipulation(path_bytes: &[u8]) -> Cow<'_, [u8]> {
Cow::Borrowed(b".")
}

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;

Expand Down
2 changes: 1 addition & 1 deletion src/uu/expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub fn uu_app() -> Command {
)
}

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
// For expr utility we do not want getopts.
// The following usage should work without escaping hyphens: `expr -15 = 1 + 2 \* \( 3 - -4 \)`
Expand Down
2 changes: 1 addition & 1 deletion src/uu/false/src/false.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use uucore::error::{UResult, set_exit_code};

use uucore::translate;

#[uucore::main]
#[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<()> {
Expand Down
2 changes: 1 addition & 1 deletion src/uu/groups/src/groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn infallible_gid2grp(gid: u32) -> String {
}
}

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;

Expand Down
2 changes: 1 addition & 1 deletion src/uu/hostid/src/hostid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use uucore::{error::UResult, format_usage};

use uucore::translate;

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
uucore::clap_localization::handle_clap_result(uu_app(), args)?;
/*
Expand Down
2 changes: 1 addition & 1 deletion src/uu/hostname/src/hostname.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ mod wsa {
}
}

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;

Expand Down
2 changes: 1 addition & 1 deletion src/uu/id/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ struct State {
user_specified: bool,
}

#[uucore::main]
#[uucore::main(no_signals)]
#[allow(clippy::cognitive_complexity)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;
Expand Down
2 changes: 1 addition & 1 deletion src/uu/link/src/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub mod options {
pub static FILES: &str = "FILES";
}

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;
let files: Vec<_> = matches
Expand Down
2 changes: 1 addition & 1 deletion src/uu/logname/src/logname.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn get_userlogin() -> Option<String> {
}
}

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let _ = uucore::clap_localization::handle_clap_result(uu_app(), args)?;

Expand Down
2 changes: 1 addition & 1 deletion src/uu/nproc/src/nproc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub const _SC_NPROCESSORS_CONF: libc::c_int = 1001;
static OPT_ALL: &str = "all";
static OPT_IGNORE: &str = "ignore";

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;

Expand Down
2 changes: 1 addition & 1 deletion src/uu/pathchk/src/pathchk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ mod options {
const POSIX_PATH_MAX: usize = 256;
const POSIX_NAME_MAX: usize = 14;

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;

Expand Down
2 changes: 1 addition & 1 deletion src/uu/pinky/src/pinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mod options {
pub const HELP: &str = "help";
}

#[uucore::main]
#[uucore::main(no_signals)]
use platform::uumain;

pub fn uu_app() -> Command {
Expand Down
2 changes: 1 addition & 1 deletion src/uu/printenv/src/printenv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static OPT_NULL: &str = "null";

static ARG_VARIABLES: &str = "variables";

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uucore::clap_localization::handle_clap_result_with_exit_code(uu_app(), args, 2)?;

Expand Down
2 changes: 1 addition & 1 deletion src/uu/pwd/src/pwd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn logical_path() -> io::Result<PathBuf> {
}
}

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;
// if POSIXLY_CORRECT is set, we want to a logical resolution.
Expand Down
2 changes: 1 addition & 1 deletion src/uu/readlink/src/readlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const OPT_ZERO: &str = "zero";

const ARG_FILES: &str = "files";

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;

Expand Down
2 changes: 1 addition & 1 deletion src/uu/realpath/src/realpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl ValueParserFactory for NonEmptyOsStringParser {
}
}

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;

Expand Down
2 changes: 1 addition & 1 deletion src/uu/test/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn uu_app() -> Command {
.after_help(translate!("test-after-help"))
}

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
let program = args.next().unwrap_or_else(|| OsString::from("test"));
let binary_name = uucore::util_name();
Expand Down
2 changes: 1 addition & 1 deletion src/uu/true/src/true.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use uucore::error::{UResult, set_exit_code};

use uucore::translate;

#[uucore::main]
#[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<()> {
Expand Down
2 changes: 1 addition & 1 deletion src/uu/tty/src/tty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod options {
pub const SILENT: &str = "silent";
}

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uucore::clap_localization::handle_clap_result_with_exit_code(uu_app(), args, 2)?;

Expand Down
2 changes: 1 addition & 1 deletion src/uu/uname/src/uname.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub struct Options {
pub os: bool,
}

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;

Expand Down
2 changes: 1 addition & 1 deletion src/uu/unlink/src/unlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use uucore::translate;

static OPT_PATH: &str = "FILE";

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;

Expand Down
2 changes: 1 addition & 1 deletion src/uu/uptime/src/uptime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl UError for UptimeError {
}
}

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;

Expand Down
2 changes: 1 addition & 1 deletion src/uu/users/src/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn get_long_usage() -> String {
translate!("users-long-usage", "default_path" => default_path)
}

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;

Expand Down
2 changes: 1 addition & 1 deletion src/uu/who/src/who.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn get_runlevel_help() -> String {
return translate!("who-help-runlevel-non-linux");
}

#[uucore::main]
#[uucore::main(no_signals)]
use platform::uumain;

pub fn uu_app() -> Command {
Expand Down
2 changes: 1 addition & 1 deletion src/uu/whoami/src/whoami.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use uucore::translate;

mod platform;

#[uucore::main]
#[uucore::main(no_signals)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
uucore::clap_localization::handle_clap_result(uu_app(), args)?;
let username = whoami()?;
Expand Down
9 changes: 6 additions & 3 deletions src/uucore_procs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ use quote::quote;
/// - Disabling Rust signal handlers for proper core dumps
/// - Error handling and exit code management
#[proc_macro_attribute]
pub fn main(_args: TokenStream, stream: TokenStream) -> TokenStream {
pub fn main(args: TokenStream, stream: TokenStream) -> TokenStream {
let stream = proc_macro2::TokenStream::from(stream);
// Some utils e.g. true does not require signals
let signals = !args.to_string().contains("no_signals");

let new = quote!(
// Initialize SIGPIPE state capture at process startup (Unix only).
// This must be at module level to set up the .init_array static that runs
// before main() to capture whether SIGPIPE was ignored by the parent process.
#[cfg(unix)]
#[cfg(all(#signals, unix))]
uucore::init_startup_state_capture!();

pub fn uumain(args: impl uucore::Args) -> i32 {
Expand All @@ -39,13 +41,14 @@ pub fn main(_args: TokenStream, stream: TokenStream) -> TokenStream {
// Restore SIGPIPE to default if it wasn't explicitly ignored by parent.
// The Rust runtime ignores SIGPIPE, but we need to respect the parent's
// signal disposition for proper pipeline behavior (GNU compatibility).
// needed even for true --version
#[cfg(unix)]
if !uucore::signals::sigpipe_was_ignored() {
let _ = uucore::signals::enable_pipe_errors();
}

// disable rust signal handlers (otherwise processes don't dump core after e.g. one SIGSEGV)
#[cfg(unix)]
#[cfg(all(#signals, unix))]
uucore::disable_rust_signal_handlers().expect("Disabling rust signal handlers failed");
let result = uumain(args);
match result {
Expand Down
Loading