Support - in optstring for getopt
POSIX states that implementations may support other characters than those specified in "Utility Syntax Guideline 3" as option arguments for getopt
. One common extension which I have verified in glibc, FreeBSD's libc, and macOS's libc, is to support -
. This allows for an interesting trick if -:
is supplied in opstring
, allowing for emulation of long options without needing getopt_long
(which is not in POSIX), though without easy support for arguments (some optind
hacking could allow for arguments, though).
At the moment, Sortix rejects getopt
calls with -
in optstring
, so a program attempting to use this trick is unable to accept any arguments.