On Wed, 26 Feb 2025 20:16:36 GMT, Nizar Benalla <nbena...@openjdk.org> wrote:

>> `jpackage` and `jar` return 0 if there are no args. `javap` returns 
>> `2`/`EXIT_CMDERR` so it's not very consistent.
>> 
>> This is the behavior when returning `CMDERR`
>> 
>> 
>> nizar-mac! $ javadoc 
>> error: Usage:
>>       javadoc [options] [packagenames] [sourcefiles] [@files]
>>   For more details on available options, use --help or --help-extra
>> 1 error
>> 
>> 
>> I'm not sure we want to emit an error? Returning 0 or 1 might better.
>> But I can understand why we would want to keep those things the same.
>
> For the record, I discussed this offline with a couple of people.
> Since the user didn't ask for the help message, this is indeed be an invalid 
> run and returning a non-zero value might  be the right thing to do.

I see, you can't return an error without generating the `error: ` prefix and 
the `1 error` line. That's a pity, as the `error: Usage:` line makes no sense, 
because the usage message is not an error message. An acceptable solution could 
be to print the usage method, and then throw the original error message, which 
produces:


Usage:
    javadoc [options] [packagenames] [sourcefiles] [@files]
For more details on available options, use --help or --help-extra
error: No modules, packages or classes specified.
1 error

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/23618#discussion_r1979693905

Reply via email to