OS X does not use GNU getopt but rather BSD getopt, which is less
friendly. Update getopt usage and argument parsing to be portable.