On Thu, Nov 25, 2021 at 11:22:11AM +0530, Bharath Rupireddy wrote: > On Thu, Nov 25, 2021 at 11:02 AM Dilip Kumar <dilipbal...@gmail.com> wrote: >> I think for parsing we use getopt_long(), as per that if you use the >> prefix of the string and that is not conflicting with any other option >> then that is allowed. So --fo, --for all are accepted, --f will not >> be accepted because --file and --format will conflict, --foo is also >> not allowed because it is not a valid prefix string of any valid >> option string. > > Yeah, that makes sense. Thanks.
It is worth noting that getopt_long() is a GNU extension and not directly something defined in POSIX, but it is so popular that it expanded everywhere. This option anme handling is quite common across everything that uses getopt_long(), actually, and erroring on non-exact option names would break a bunch of existing use cases as it is possible to save some characters if getopt_long() is sure of the uniqueness of the option found. -- Michael
signature.asc
Description: PGP signature