if $OPTIND value start from 1 then i think "-b" $OPTIND should be "3" like sh
but bash print "2"

set -- -a -bc hello world

echo $OPTIND                    # sh, bash  = 1

getopts abc opt "$@"  
echo $opt, $OPTIND           # sh, bash = a, 2

getopts abc opt "$@"          # bash  = b, 2                  <------ different 
from "sh"
echo $opt, $OPTIND            # sh      = b, 3        

getopts abc opt "$@"         # sh, bash = c, 3
echo $opt, $OPTIND

Reply via email to