coreutils: --list arg and no args should fail

This commit is contained in:
oech3
2026-03-30 10:56:33 +02:00
committed by Daniel Hofstetter
parent aaeb4849fc
commit 02bc8e0dc3
+12 -7
View File
@@ -85,10 +85,10 @@ fn main() {
match util {
"--list" => {
// If --help is also present, show usage instead of list
if args.any(|arg| arg == "--help" || arg == "-h") {
usage(&utils, binary_as_util);
process::exit(0);
// we should fail with additional args https://github.com/uutils/coreutils/issues/11383#issuecomment-4082564058
if args.next().is_some() {
let _ = writeln!(io::stderr(), "coreutils: invalid argument");
process::exit(1);
}
let mut out = io::stdout().lock();
for util in utils.keys() {
@@ -156,8 +156,13 @@ fn main() {
}
}
} else {
// no arguments provided
usage(&utils, binary_as_util);
process::exit(0);
// GNU just fails, but busybox tests needs usage
// todo: patch the test suite instead
if binary_as_util.ends_with("box") {
usage(&utils, binary_as_util);
} else {
let _ = writeln!(io::stderr(), "coreutils: missing argument");
}
process::exit(1);
}
}