Next: getopts types, Up: getopts [Index]
Command line arguments are available through the command-line
function from the (rnrs programs (6))
library. For the purposes of
this documentation, command line arguments are divided into three
categories:
A string selecting a configuration option that can be turned on or off. It can be a single character (brief option) or a full–word (long option).
A string selecting a value for a configuration option; an option’s value is a string of any length, including the empty string.
A value to be passed to the program.
Let’s assume that:
the following command line chunks are so interpreted:
-vh -o green -i -Iwhite -f red
The -v, -h and -i options without value; the -o option with value ‘green’; the -I option with value ‘white’; the -f option with value ‘red’.
--verbose --help --output=green --interactive
--include white --file=red
The --verbose, --help and --interactive options without value; the --output option with value ‘green’; the --include option with value ‘white’; the --file option with value ‘red’.
The argument --
is recognised as “end of options” marker: all
the arguments following it are interpreted as non–options, even if
their string starts with a dash or double dash.
Chains of brief options are allowed: the options -v,
-i and -h can be selected with the single argument
-vih
. Notice, though, that only options with no value can be
chained; an option with value can appear only as last in the train, with
no value attached. For example:
-vihI white
is interpreted as the options -v, -i and -h with no value followed by the option -I with value ‘white’; the following:
-vihIwhite ;forbidden
could be made possible but, being unreadable, it is forbidden.
Notice that a single dash, ‘-’, is a valid non–option argument.
Next: getopts types, Up: getopts [Index]