1getopts optstring name [ arg ... ]
2       Checks the args for legal options.  If the args are omitted, use
3       the  positional parameters.  A valid option argument begins with
4       a `+' or a `-'.  An argument not beginning with a `+' or a  `-',
5       or  the argument `--', ends the options.  Note that a single `-'
6       is not considered a valid option argument.   optstring  contains
7       the letters that getopts recognizes.  If a letter is followed by
8       a `:', that option requires an argument.   The  options  can  be
9       separated from the argument by blanks.
10
11       Each  time  it  is  invoked, getopts places the option letter it
12       finds in the shell parameter name, prepended with a `+' when arg
13       begins  with  a  `+'.   The  index  of the next arg is stored in
14       OPTIND.  The option argument, if any, is stored in OPTARG.
15
16       The first option to be examined may  be  changed  by  explicitly
17       assigning  to  OPTIND.  OPTIND has an initial value of 1, and is
18       normally reset to 1 upon exit from a shell function.  OPTARG  is
19       not  reset  and  retains  its value from the most recent call to
20       getopts.  If either of OPTIND or OPTARG is explicitly unset,  it
21       remains  unset,  and the index or option argument is not stored.
22       The option itself is still stored in name in this case.
23
24       A leading `:' in optstring causes getopts to store the letter of
25       any  invalid  option  in  OPTARG,  and to set name to `?' for an
26       unknown option and to `:' when a required argument  is  missing.
27       Otherwise,  getopts sets name to `?' and prints an error message
28       when an option is invalid.  The  exit  status  is  nonzero  when
29       there are no more options.
30