## 7 Syntax of command-line arguments ¶

POSIX recommends these conventions for command-line arguments.

- A command-line argument is an option if it begins with a hyphen (‘`-`’).
- Option names are single alphanumeric characters.
- Certain options require an argument.
- An option and its argument may or may not appear as separate tokens. (In other words, the whitespace separating them is optional). Thus, `-o foo` and `-ofoo` are equivalent.
- One or more options without arguments, followed by at most one option that takes an argument, may follow a hyphen in a single token. Thus, `-abc` is equivalent to `-a -b -c`.
- Options typically precede other non-option arguments.
- The argument ‘`--`’ terminates all options; any following arguments are treated as non-option arguments, even if they begin with a hyphen.
- A token consisting of a single hyphen character is interpreted as an ordinary non-option argument. By convention, it is used to specify standard input, standard output, or a file named ‘`-`’.

GNU adds long options to these conventions:

- A long option consists of two hyphens (‘`--`’) followed by a name made of alphanumeric characters and hyphens. Option names are typically one to three words long, with hyphens to separate words. Abbreviations can be used for the long option names as long as the abbreviations are unique.
- A long option and its argument may or may not appear as separate tokens. In the latter case they must be separated by an equal sign ‘`=`’. Thus, `--foo bar` and `--foo=bar` are equivalent.

The syntax of options with an optional argument is `-<short_option><argument>` (without whitespace), or `--<long_option>=<argument>`.