/usr/lib/getoptcvt reads the shell script in filename, converts it to use getopts instead
of getopt, and writes the results on the standard output.
getopts is a built-in Bourne shell command used
to parse positional parameters and to check for valid options. See sh(1). It supports all applicable rules of
the command syntax standard (see Rules 3-10, intro(1)).
It should be used in place of the getopt command. (See
the NOTES section below.) The syntax for the shell's built-in getopts command is:
getopts optstring name [ argument...]
optstring must contain the option letters
the command using getopts will recognize; if a letter
is followed by a colon (:), the option is expected to
have an argument, or group of arguments, which must be separated from it
by white space.
Each time it is invoked, getopts places the next
option in the shell variable name and the index
of the next argument to be processed in the shell variable OPTIND. Whenever the shell or a shell script is invoked, OPTIND is initialized to 1.
When an option requires an option-argument, getopts
places it in the shell variable OPTARG.
If an illegal option is encountered, ? will be
placed in name.
When the end of options is encountered, getopts
exits with a non-zero exit status. The special option -- may be used to delimit the end of the options.
By default, getopts parses the positional parameters.
If extra arguments (argument ...)
are given on the getopts command line, getopts parses them instead.
So that all new commands will adhere to the command syntax standard
described in intro(1), they should
use getopts or getopt to parse positional
parameters and check for options that are valid for that command (see the NOTES
section below).
|