From 62f5383e1619f745d4ac0f08063f606447125a47 Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Tue, 17 Mar 2026 22:35:34 +0900 Subject: [PATCH] coreutils: --help args is same with --help --- src/bin/coreutils.rs | 20 +------------------- tests/test_util_name.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/bin/coreutils.rs b/src/bin/coreutils.rs index 84c7ff0ab85..f451780250a 100644 --- a/src/bin/coreutils.rs +++ b/src/bin/coreutils.rs @@ -125,26 +125,8 @@ fn main() { process::exit(uumain(vec![util_os].into_iter().chain(args))); } None => { + // GNU coreutils --help string shows help for coreutils if util == "--help" || util == "-h" { - // see if they want help on a specific util - if let Some(util_os) = args.next() { - let Some(util) = util_os.to_str() else { - validation::not_found(&util_os) - }; - - match utils.get(util) { - Some(&(uumain, _)) => { - let code = uumain( - vec![util_os, OsString::from("--help")] - .into_iter() - .chain(args), - ); - io::stdout().flush().expect("could not flush stdout"); - process::exit(code); - } - None => validation::not_found(&util_os), - } - } usage(&utils, binary_as_util); process::exit(0); } else if util.starts_with('-') { diff --git a/tests/test_util_name.rs b/tests/test_util_name.rs index 53c3ef55334..71d6f6ebeac 100644 --- a/tests/test_util_name.rs +++ b/tests/test_util_name.rs @@ -40,6 +40,18 @@ fn binary_name_protection() { .stdout_contains("coreutils"); } +#[test] +fn test_coreutils_help_ignore_args() { + let scenario = TestScenario::new("help_ignoring_args"); + let output = std::process::Command::new(&scenario.bin_path) + .arg("--help") + .arg("---") + .output() + .unwrap(); + + assert_eq!(output.status.code(), Some(0)); +} + #[test] #[cfg(feature = "ls")] fn execution_phrase_double() {