getopts

It is designed to process command line arguments that follow the POSIX Utility Syntax Guidelines, based on the C interface of getopt.

The original getopt had several problems: it could not handle whitespace or shell metacharacters in arguments, and there was no ability to disable the output of error messages.

In 1995, getopts was included in the Single UNIX Specification version 1 / X/Open Portability Guidelines Issue 4.

[5] The modern usage of getopt was partially revived mainly due to an enhanced implementation in util-linux.

In addition, all programs are of the form: The old getopt does not support optional arguments: This script will also break with any article title with a space or a shell metacharacter (like ?

[10] Linux getopt escapes its output and an "eval" command is needed to have the shell interpret it.