Node:Argument Syntax, Next:Parsing Program Arguments, Up:Program Arguments
POSIX recommends these conventions for command line arguments.
getopt
(see Getopt) and argp_parse
(see Argp) make
it easy to implement them.
-
).
-abc
is equivalent to
-a -b -c
.
isalnum
;
see Classification of Characters).
-o
command
of the ld
command requires an argument--an output file name.
-o foo
and -ofoo
are equivalent.
The implementations of getopt
and argp_parse
in the GNU C
library normally make it appear as if all the option arguments were
specified before all the non-option arguments for the purposes of
parsing, even if the user of your program intermixed option and
non-option arguments. They do this by reordering the elements of the
argv array. This behavior is nonstandard; if you want to suppress
it, define the _POSIX_OPTION_ORDER
environment variable.
See Standard Environment.
--
terminates all options; any following arguments
are treated as non-option arguments, even if they begin with a hyphen.
GNU adds long options to these conventions. Long options consist
of --
followed by a name made of alphanumeric characters and
dashes. Option names are typically one to three words long, with
hyphens to separate words. Users can abbreviate the option names as
long as the abbreviations are unique.
To specify an argument for a long option, write
--name=value
. This syntax enables a long option to
accept an argument that is itself optional.
Eventually, the GNU system will provide completion for long option names in the shell.