BSD vs GNU getopt(3) semantics

Issue #118 resolved
Takehiko NOZAKI repo owner created an issue

see OpenBSD's commit log:

GNU semantics say that if optstring begins with '-' then
each non-option shall be treated as arguments to option '\1'.

BSD getopt match '-' in optstring with a '-' on the command line.
This is used to support deprecated options like "su -" that would
otherwise prevent the use of getopt().

Resolving this simply requires that the leading '-' be moved somewhere
else (I moved it to the end of optstring) since position within
optstring is not meaningful.

Comments (2)

  1. Log in to comment