Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

numeric parameter conversion should parse as decimal #72

Closed
remkop opened this issue Mar 25, 2017 · 0 comments
Closed

numeric parameter conversion should parse as decimal #72

remkop opened this issue Mar 25, 2017 · 0 comments

Comments

@remkop
Copy link
Owner

remkop commented Mar 25, 2017

Currently:
Byte, short, int and long conversion (for both primitives and wrappers) uses the decode method, so numbers starting with 0x, 0X or # are interpreted as hexadecimal numbers, numbers starting with 0 are interpreted as octal numbers, and otherwise the number is interpreted as a decimal number.

But see POSIX Utility Conventions Requirement 6:

Unless otherwise specified, whenever an operand or option-argument is, or contains, a numeric value:
The number is interpreted as a decimal integer.

Perhaps using the decode method by default is not a good idea.
Let's revert to the parse methods that interpret as a decimal value, and in the documentation suggest that applications that want to support hex values register the decode method:

commandLine.registerConverter(Integer.class, s -> Integer::decode);

@remkop remkop added this to the 0.4.0 user manual milestone Mar 25, 2017
@remkop remkop closed this as completed in 86244b7 Mar 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant