Use POSIX getopts (plural).

See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/getopts.html.