The OPTIND environment variable is set by getopts to the index of the next option it will process. It is automatically set to 1 at the beginning of any function or script. You can set it by hand to force getopts to process a particular positional parameter.