Skip to content

Commit 36265cb

Browse files
oech3sylvestre
authored andcommitted
coreutils: --help args is same with --help
1 parent ef5243e commit 36265cb

2 files changed

Lines changed: 13 additions & 19 deletions

File tree

src/bin/coreutils.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -125,26 +125,8 @@ fn main() {
125125
process::exit(uumain(vec![util_os].into_iter().chain(args)));
126126
}
127127
None => {
128+
// GNU coreutils --help string shows help for coreutils
128129
if util == "--help" || util == "-h" {
129-
// see if they want help on a specific util
130-
if let Some(util_os) = args.next() {
131-
let Some(util) = util_os.to_str() else {
132-
validation::not_found(&util_os)
133-
};
134-
135-
match utils.get(util) {
136-
Some(&(uumain, _)) => {
137-
let code = uumain(
138-
vec![util_os, OsString::from("--help")]
139-
.into_iter()
140-
.chain(args),
141-
);
142-
io::stdout().flush().expect("could not flush stdout");
143-
process::exit(code);
144-
}
145-
None => validation::not_found(&util_os),
146-
}
147-
}
148130
usage(&utils, binary_as_util);
149131
process::exit(0);
150132
} else if util.starts_with('-') {

tests/test_util_name.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ fn binary_name_protection() {
4040
.stdout_contains("coreutils");
4141
}
4242

43+
#[test]
44+
fn test_coreutils_help_ignore_args() {
45+
let scenario = TestScenario::new("help_ignoring_args");
46+
let output = std::process::Command::new(&scenario.bin_path)
47+
.arg("--help")
48+
.arg("---")
49+
.output()
50+
.unwrap();
51+
52+
assert_eq!(output.status.code(), Some(0));
53+
}
54+
4355
#[test]
4456
#[cfg(feature = "ls")]
4557
fn execution_phrase_double() {

0 commit comments

Comments
 (0)