changed mgetopt to more closely match POSIX behavior