Handling bad values when parsing function arguments in bash
I want to handle bad values when parsing function arguments in bash. What can I do?
Bad values for -v (not 1,2 or 3) makes the function go wrong when parsing arguments.
myfunc -v 1eo -g -W 3Here is the code
while (( $# > 0 )); do opt="$1" case $opt in ("-v"|"--verbiage") if [[ $2 == [1-3] ]]; then vb="$2" ; shift ; shift else vb=1 ; shift 1 fi ;; ("-g") glob_ptrn=1 ; shift 1 ;; (*) break ;; esac done 4 Reset to default