matejak / argbash

Bash argument parsing code generator
Other
1.4k stars 62 forks source link

Invalid short and long options are treated as positional arguments #162

Closed gdevenyi closed 2 years ago

gdevenyi commented 2 years ago

If I typo an argument, or provide one that the script doesn't actually understand, say --verbat instead of --verbose, the unparsed option ends up as a positional argument, instead of the properly-supplied positional argument.

Related to #22

gdevenyi commented 2 years ago

To clarify, I think unless ARGBASH_LEFTOVERS is used, unparsed argument should throw an error.

matejak commented 2 years ago

This is expected, but as indicated in an answer to #22, there is an existing remedy to this kind of problems. Proper handing of this is probably out of scope of Argbash - you can write your own function to validate supplied values, throwing an appropriate error s.a. "the value looks like an option, while we expect a number", or something like that. Therefore, I close this issue, but feel free to reopen if you feel that it has been misunderstood.