引自
the POSIX.1-2008 description about
-W
option,
The -W
(capital-W) option shall be reserved for vendor options.
引自Linux手册页面,GNU getopt handles -W
option as follows:
If optstring contains W followed by a semicolon ( ; ),then -W foo
is treated as the long option --foo
. (The -W option is reserved by POSIX.2 for implementation extensions.)
有人能够以更清晰的方式解释上述句子(直截了当)并解释为什么这样的选项有用吗?
上面的语句让我感到困惑,因为我认为getopt(不是getopt_long,getopt_long_only)只能理解短选项.
退房:
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.