I have a loop to parse command line arguments. Everything works fine if -d or -b argument has a parameter. But when I pass -d or -b without a parameter, the script gets into infinite loop.
# Parse command line input
while [ "$#" -gt 0 ]; do
case "$1" in
-d) DOMAIN="$2"; shift 2;;
-b) BITS="$2"; shift 2;;
*) die "unrecognized argument: $1"
esac
done
How to throw error on empty parameter?