BSD getopt does not work

Hey, your script is just great and I was looking for something like that just 2 days ago so thank you! Sadly it was not working with BSD getopt version so I wrote a patch for it.

Thanks again!