Use shell built-in getopt for option parsing

This should work on Macs because it's basically copied from Aleks' work
in the scala-frontend branch