Chapter 26. Parsing Command-Line Options
Most Linux programs allow the user to specify command-line options. Such options perform a wide variety of functions but are fairly uniform in their syntax. Short options consist of a
- character followed by a single alphanumeric character. Long options, common in GNU utilities, consist of two
- characters followed by a string made up of letters, numbers, and hyphens. Either type of option may be followed by an argument. A space separates a short option from its arguments; either a space or an
= separates a long option from an argument.
There are many ways of parsing command-line options. The most popular method is parsing the
argv array by hand. The library functions
getopt_long() provide some ...