30/07/2020
The term options, option-arguments, and operands and their syntax
Options
utility_name [-a]
The term options consist of hyphen-minus characters (that is ‘-’) followed by single letters or digits.
Option-arguments
utility_name [-c option_argument] # This option_argument is mandatory
utility_name [-f[option_argument]] # This option_argument is optional
Certain options are followed by an “option-argument”, as shown with [ -c option_argument].
Option-arguments are shown separated from their options by characters (or space character), except when the option-argument is enclosed in the ‘[‘ and ‘]’ notation (or square brackets) to indicate that it is optional.
If the SYNOPSIS shows an optional option-argument (as with [ -f[ option_argument]] in the example) and the utility receives an argument containing only the option, it should behave as specified in its description for an omitted option-argument.
utility_name[-a][-b][-c option_argument][operand...]
When multiple option-arguments are specified to follow a single option, they should be presented as a single argument, using (that is ‘,’ ) characters within that argument or characters within that argument to separate them.
utility_name -c option_argument,option_argument2,option_argument3
utility_name -c option_argument option_argument2 option_argument3
Operands
Finally, arguments following the last options and option-arguments are named “operands”.
Some things to note:
1. When a utility has a few permissible options, they are sometimes shown individually. Utilities with many flags generally show all of the individual flags (that do not take option-arguments) grouped. This means
utility_name [-abc][-p arg][operand]
is the same as
utility_name [-a][-b][-c][-p arg][operand]
2. Utilities with very complex arguments may be shown as follows:
utility_name [options][operands]
3. Arguments or option-arguments enclosed in the ‘[‘ and ‘]’ notation are optional and can be omitted.
4. When the SYNOPSIS line is too long to be printed on a single line in the Shell and Utilities volume of POSIX.1–2017, the indented lines following the initial line are continuation lines. An example of this would be git pull SYNOPSIS.
Arguments separated by the ‘|’ ( ), also known as bar notation, are mutually-exclusive.
utility_name [-d|-e]
This means you can only use -d or -e in a command, but not both.
utility_name -d # This works
utility_name -e # This works
utility_name -d -e # This doesn't work
When multiple synopsis lines are given for a utility, it is an indication that the utility has mutually-exclusive arguments.
An example of this would be git branch command:
# Here lies a snippet of git branch SYNOPSIS..
git branch (-c | -C) []
git branch (-d | -D) [-r] …..
These mutually-exclusive arguments alter the functionality of the utility so only one of the mutually-exclusive arguments is allowed for invocation of the utility.
This means you can’t do
git branch -c -d
Ellipses ( “…” ) are used to denote that one or more occurrences of an operand are allowed.
When an option or an operand followed by ellipses is enclosed in brackets, zero or more options or operands can be specified. The form:
utility_name [-g option_argument]...[operand...]
indicates that multiple occurrences of the option and its option-argument preceding the ellipses are valid. E.g. utility_name -g hello -g hello
The form:
utility_name -f option_argument [-f option_argument]... [operand...]
indicates that the -f option is required to appear at least once and may appear multiple times.
If an argument can be identified as an option, or as a group of options without option-arguments behind one ‘-’ delimiter, then it should be treated as such.
An example of this would be ps.
If you have ever stumbled on a Linux man page, chances are, you would have seen something like this at the top of the page: