Quoted from the POSIX.1-2008 description about -W option,
The
-W(capital-W) option shall be reserved for vendor options.
Quoted from Linux Manual page, GNU getopt handles -W option as follows:
If optstring contains W followed by a semicolon ( ; ), then
-W foois treated as the long option--foo. (The -W option is reserved by POSIX.2 for implementation extensions.)
Could someone explain the above sentence in a more clear way (straightforward) and explain why such an option is useful?
The above statement bugs me because I think getopt (not getopt_long, getopt_long_only) only understand short options.
Check out: http://www.gnu.org/software/gnuprologjava/api/gnu/getopt/Getopt.html
Long options can also be specified using a special POSIX argument format (one that I highly discourage). This form of entry is enabled by placing a "W;" (yes, 'W' then a semi-colon) in the valid option string. This causes getopt to treat the name following the "-W" as the name of the long option. For example, "-W outputdir=foo" would be equivalent to "--outputdir=foo". The name can immediately follow the "-W" like so: "-Woutputdir=foo". Option arguments are handled identically to normal long options. If a string follows the "-W" that does not represent a valid long option, then getopt() returns 'W' and the caller must decide what to do. Otherwise getopt() returns a long option value as described below.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With