Free Pascal => General => Topic started by: jollytall on October 12, 2021, 07:02:57 pm

Title: GetOpt leading -: handled incorrectly
Post by: jollytall on October 12, 2021, 07:02:57 pm
When I call GetLongOpts (see the other two topics too) for a simple
Code: [Select]
ShortOpts = 'a:' then BOTH for
Code: [Select]
>./test -a
>./test -b
I should get a ? back. No difference between an option with a missing mandatory argument and a non-existent option. This works fine.

Code: [Select]
ShortOpts = ':a:' i.e. a leading : in front of the list of options, it means that the two cases should be different. For a missing mandatory argument I should get back a :, while for a non-existent option should still get back a ?. This one also works as intended.

I can also define
Code: [Select]
ShortOpts = '-:a:' The extra leading - only means that non-option values are just returned with a #0, but the rest should work the same way. Still, in this case it seems GetOpts does not take into account the : and returns a ? both for missing mandatory arguments and for a non-existent option.

I think it is a bug (unless I made something wrong).
TinyPortal © 2005-2018