Unix system, options begin with
- is short option, while options begin with
-- is long option. Is my understanding right?
That is part of the GNU coding standards, so all GNU (and many non-GNU) software follows it. However, it's by no means an absolute standard; there are other ways of implementing this, such as:
-Wlong-option: originated from the C compiler, and specified as such in POSIX.
-long-option(i.e., single-dash): supported by most applications (usually as an alternative to the double-dash version) that don't have any short options.
+long-option: this is getting out of fashion, but there are a few older software packages that reserved the dash for short options, and the plus sign for long options. Not used much today, mostly because most getopt() implementations don't support it
long-option: unfortunately there are also some applications which confuse options with arguments. I believe MegaCLI is one of the offenders there (it is an offender in pretty much everything else, anyway).
--long-opt method is a GNUism that has been initiated around 1990.
-long options with a single dash and the Multics project was initiated the 1960s.
UNOS is the first
UNIX clone (initiated by a group of former AT&T employees in 1980) and
UNOS introduced a generalized option parser (the first in the
UNIX world) in April 1982. This option parser supported
-long options with a single dash.
getopt() between 1983 and 1984, but
getopt() was not reentrant before an additional 4th global variable has been introduced in 1989 for the Bourne Shell's builtin
POSIX implements operands that look like long options with a single dash with
AT&T UNIX introduced
-long options using a single dash around 1983 while permitting e.g.
kill -INT <pid>.
ar did not use the term
option in their documentation at all but rather used the term
keyletter. Later, implementors added support for a
- keyletter that is ignored, giving the impression that y CLI may look like other UNIX commands.
dd uses an own option model, but this option model is compatible with the long option model from
UNOS that defines long options to be in the following form:
UNOS option parser is superior to the GNU longopt implementation as it uses a format string that allows to auto-convert integer and boolean arguments and as it allows to implement callback functions for eny option if desired. There is no need to reorder the argument list because of the callback function interface.
getopt() implementation supports long options as aliases to short options since 2004 but did not really document it even though it was usable by the
Bourne Shell via
getopts(1)since it was introduced.
Schily Bourne Shell documents this feature and in addition introduced further
getopt() enhancements that permit long options that are not just aliases to a short option and that permit single dash long options.
See http://schillix.sourceforge.net/man/man1/bosh.1.html in the builtin commands section for
A modernized and enhanced option parser that is based on the ideas of the
UNOS option parser is in the schily-tools in
it is used in the schily tool programs that are not based on AT&T code and results in less problems with unhappy defined options names such as in