
Neal D. Becker wrote:
There are 2 choices:
1) Don't correctly parse some correct cases
or
2) Give confusing error message for incorrect case.
You'll agree #2 is better than #1.
Yes, I do agree.
So:
-a -3
where -3 is a valid option, and -a takes a value.
Well... if we agree that "-a -3" is a correct case, then it should be handled. The reason why I'm suspicious is that it's clearly ambiguous, and I prefer to handle ambiguity as error. OTOH, "token following option with value is always value" is a simple rule, which is good. Things get more messy if "-a" has *optional* value. Should we parse "-3" as value, or as option. In fact, I wonder if we should have optional values at all, but that's a topic for a separate post.
I'm not sure what gnu getopt does in this case (although it seems to always do the right thing (TM), because I'm sure I've used this and never noticed a problem).
Jonathan say getopt does what your propose, which does qualify as good argument. I've made the change in revision 289. Thanks, Volodya