mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
coreutils: --list arg and no args should fail
This commit is contained in:
+12
-7
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user