The shell initialises global variable OPTIND to 1 on start up. In order to use
getopts in functions, OPTIND must be reinitialised before calling getopts. In
bash, it suffices to make OPTIND local, but in busybox, OPTIND must also be set
I also fixed a few formatting slips.