5 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/getopt.html}
7 Gnulib module: getopt-posix or getopt-gnu
9 The module @code{getopt-gnu} has support for ``long options'' and for
10 ``options that take optional arguments''. Compared to the API defined by POSIX,
11 it adds a header file @code{<getopt.h>} and a function @code{getopt_long}.
13 Portability problems fixed by either Gnulib module @code{getopt-posix} or @code{getopt-gnu}:
16 The @code{getopt} function keeps some internal state that cannot be explicitly
17 reset on some platforms:
20 The value of @code{optind} after a missing required argument is wrong
25 Portability problems fixed by Gnulib module @code{getopt-gnu}:
28 The function @code{getopt} does not support the @samp{+} flag in the options
29 string on some platforms:
30 MacOS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10.
32 The function @code{getopt} does not obey the combination of @samp{+}
33 and @samp{:} flags in the options string on some platforms:
36 The function @code{getopt} does not obey the @samp{-} flag in the options
37 string when @env{POSIXLY_CORRECT} is set on some platforms:
40 The function @code{getopt} does not support options with optional arguments
42 MacOS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11, IRIX 6.5, OSF/1 5.1,
43 Solaris 10, Cygwin 1.5.x.
45 The function @code{getopt_long} is missing on some platforms:
46 AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Interix 3.5.
48 The function @code{getopt_long_only} is missing on some platforms:
49 MacOS X 10.3, FreeBSD 5.2.1, NetBSD 3.0, AIX 5.1, HP-UX 11, IRIX 6.5,
50 OSF/1 5.1, Solaris 9, mingw, Interix 3.5.
53 Portability problems not fixed by Gnulib:
56 The default behavior of the glibc implementation of @code{getopt} allows
57 mixing option and non-option arguments on the command line in any order.
58 Other implementations, such as the one in Cygwin, enforce strict POSIX
59 compliance: they require that the option arguments precede the non-option
60 arguments. This is something to watch out in your program's
63 The glibc implementation allows a complete reset of the environment,
64 including re-checking for @env{POSIXLY_CORRECT}, by setting
65 @code{optind} to 0. Several BSD implementations provide @code{optreset},
66 causing a reset by setting it non-zero, although it does not
67 necessarily re-read @env{POSIXLY_CORRECT}. Solaris @code{getopt} does
68 not support either reset method, but does not maintain state that
69 needs the extra level of reset.