so if I understand an summarize correctly we'd change

- the usage() for all to return 1
- print messages on exceptions to System.err
- rethrow the exception so java can handle it if it will terminate afterwards 
anyway
- use something above 2 and below 126 as an error code for System.exit() if 
rethrowing doesn't make sense

OK?

Maruan


Am 15.01.2015 um 19:03 schrieb John Hewson <j...@jahewson.com>:

> If the usage was printed due to invalid command line parameters, then the 
> convention on Unix is to return exit code 1. We should be doing that too.
> 
> Note than if Java throws an exception which causes main() to exit and there 
> is no catch clause, then java will return a non-zero code of its own accord. 
> If we’re catching fatal exceptions in main, then we should System.exit(1) 
> afterwards.
> 
> -- John
> 
>> On 15 Jan 2015, at 09:13, Maruan Sahyoun <sahy...@fileaffairs.de> wrote:
>> 
>> Yes,
>> 
>> current behavior within the tools 
>> usage(): some tools have a System.exit, some don't and for the ones they 
>> have the exit code is not always the same.
>> -main() there is no System.exit for the ones I looked at in case of an 
>> error. Only an error message is written to System.err
>> 
>> You'd rather expect System.exit > 0 in case there is an issue in main 
>> processing and then System.exit as part of usage makes sense. If there is 
>> none on main there shouldn't be one on usage().
>> 
>> So I'd remove it on usage() too.
>> 
>> WDYT?
>> 
>> Maruan 
>> 
>> Am 15.01.2015 um 18:00 schrieb Andreas Lehmkuehler <andr...@lehmi.de>:
>> 
>>> Hi,
>>> 
>>> Am 15.01.2015 um 17:20 schrieb John Hewson:
>>>> Only if there's a non-zero number  used as the argument.
>>> Yes, but IMO such a value is only useful if there is any processing issue. 
>>> Maruans question targets those calls within the usage message which is 
>>> shown only if there is any issue with the given commandline parameters.
>>> 
>>> I'd remove such calls.
>>> 
>>>> -- John
>>>> 
>>>>> On 15 Jan 2015, at 06:06, Maruan Sahyoun <sahy...@fileaffairs.de> wrote:
>>>>> 
>>>>> Hi,
>>>>> 
>>>>> do we need System.exit() in our command line tools usage messages? 
>>>>> Opinions? Don't see a benefit of having them.
>>>>> 
>>>>> BR
>>>>> Maruan
>>> 
>>> BR
>>> Andreas LEhmkühler
>> 
> 

Reply via email to