Getops for command line options

Instead of complex $0, $1, etc just use getopts