Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

getopts / OPTIND / shift : inconsistent behavior



Hi,

With zsh 4.3.4 the OPTIND incremental bebavior is inconsistent for options 
with argument and without argument. For option with argument, OPTIND points 
to next argument, while for option without argument it points to current 
argument.

func() {
getopts a:b optvar
shift $(( OPTIND -1 ))
echo "$OPTIND, $1"
}

func -a x y z
output: 3, y

func -b x y z
output: 1, -b

Is this a bug? There is no consistent way to do "shift" as such.



Messages sorted by: Reverse Date, Date, Thread, Author