After getopt has returned -1, the global variable optind holds the index of the first argument that was not part of the command-line options.
getopt返回- 1后,全局变量optind保存第一个不属于命令行选项的参数的索引。
The showopts function analyzes the options as before, but USES the return statement to return the value of the OPTIND variable to the calling statement.
showopts函数像以前一样分析选项,但是使用return语句将OPTIND变量的值返回给调用语句。
You will need to reset OPTIND to 1 yourself if you call getopts for a new set of arguments in a script where you have already used it with other arguments.
如果您在脚本中已经使用一组参数调用了getopts,现在要用另一组参数来调用它,则需要亲自将OPTIND重置为1。
应用推荐