Skip to content

Commit 8da2a17

Browse files
committed
coreutils: --help args is same with --help
1 parent 0beca7c commit 8da2a17

2 files changed

Lines changed: 19 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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,24 @@ fn init() {
2626
eprintln!("Setting UUTESTS_BINARY_PATH={TESTS_BINARY}");
2727
}
2828

29+
#[test]
30+
fn test_coreutils_help_ignore_args() {
31+
use std::process::Command;
32+
33+
let scenario = TestScenario::new("help_ignoring_args");
34+
if !scenario.bin_path.exists() {
35+
return;
36+
}
37+
38+
let output = Command::new(&scenario.bin_path)
39+
.arg("--help")
40+
.arg("---")
41+
.output()
42+
.unwrap();
43+
44+
assert_eq!(output.status.code(), Some(0));
45+
}
46+
2947
#[test]
3048
#[cfg(feature = "ls")]
3149
fn execution_phrase_double() {

0 commit comments

Comments
 (0)