4 ms·
Unfortunately, this isn't quite true. At least if by Unix you mean POSIX, i.e. you include macOS in your considerations. 1. Sadly, short options are in fact mo
by ucarion 6y ago
Unfortunately, this isn't quite true. At least if by Unix you mean POSIX, i.e. you include macOS in your considerations.
1. Sadly, short options are in fact more portable than long options if you're targeting POSIX. For instance, macOS ships with versions of ls, rm, et cetera that only support short flags. This is because long options don't exist at all in POSIX (they're formalized here: https://pubs.opengroup.org/onlinepubs/009695399/functions/getopt.html https://pubs.opengroup.org/onlinepubs/009695399/functions/ge...).
2. Auto-completing partial options only happens for long flags, and it's a bit more than "some" parsers; the canonical implementation of "long" options, GNU's getopt_long, has it as a documented feature:
> Long option names may be abbreviated if the abbreviation is unique or is an exact match for some defined option.
https://linux.die.net/man/3/getopt_long https://linux.die.net/man/3/getopt_long
I 100% agree it's a poor feature. You basically entirely preclude yourself from adding features in a backwards-compatible way.