fixed getopts usage, bashisms