Skip to content

Usage errors from clap produce exit status 2 but GNU programs produce exit status 1 #3102

@jfinkels

Description

@jfinkels

This is the same issue I reported previously in #2951, but I noticed that this is a general problem with all programs. The problem is that usage errors that arise from argument parsing (for example, due to conflicting options or missing arguments) in uutils programs cause the process to terminate with exit status 2. But in GNU programs, the process terminates with exit status 1.

For example,

GNU head:

$ head --lines
head: option '--lines' requires an argument
Try 'head --help' for more information.
$ echo $?
1

uutils head:

$ ./target/debug/head --lines
error: The argument '--lines <[-]NUM>' requires a value but none was supplied

USAGE:
    head [FLAG]... [FILE]...

For more information try --help
$ echo $?
2

If there is a uniform solution that could be applied to all programs, that would likely help with a lot of test cases in the GNU test suite. For example, there are several test cases in tests/misc/uniq.pl that expect exit code 1 where we currently return exit code 2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions