OSX awk requires a space after the -v option.
Use POSIX getopts (plural).

See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/getopts.html.
Fail on invalid argument.

getopts outputs a decent error message to stderr so no need to call
die().
Put back shifts so action is found at $1.
Merge pull request #2 from mbucc/master

POSIX getopts and awk