Skip to content

Commit 02bc8e0

Browse files
oech3cakebaker
authored andcommitted
coreutils: --list arg and no args should fail
1 parent aaeb484 commit 02bc8e0

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/bin/coreutils.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ fn main() {
8585

8686
match util {
8787
"--list" => {
88-
// If --help is also present, show usage instead of list
89-
if args.any(|arg| arg == "--help" || arg == "-h") {
90-
usage(&utils, binary_as_util);
91-
process::exit(0);
88+
// we should fail with additional args https://github.com/uutils/coreutils/issues/11383#issuecomment-4082564058
89+
if args.next().is_some() {
90+
let _ = writeln!(io::stderr(), "coreutils: invalid argument");
91+
process::exit(1);
9292
}
9393
let mut out = io::stdout().lock();
9494
for util in utils.keys() {
@@ -156,8 +156,13 @@ fn main() {
156156
}
157157
}
158158
} else {
159-
// no arguments provided
160-
usage(&utils, binary_as_util);
161-
process::exit(0);
159+
// GNU just fails, but busybox tests needs usage
160+
// todo: patch the test suite instead
161+
if binary_as_util.ends_with("box") {
162+
usage(&utils, binary_as_util);
163+
} else {
164+
let _ = writeln!(io::stderr(), "coreutils: missing argument");
165+
}
166+
process::exit(1);
162167
}
163168
}

0 commit comments

Comments
 (0)