how to check whether there was no required argument provided? I found that ":" option in switch case should be sufficient for this purpose, but it never enters that case (codeblock). It doesn't matter whether I put "colon-case" at the beginning or elsewhere.
my code:
while getopts :a:b: OPTION;
do
case "$OPTION" in
a)
var1=$OPTARG
;;
b)
var2=$OPTARG
;;
?)
exitScript "`echo "Invalid option $OPTARG"`" "5"
;;
:)
exitScript "`echo "Option -$OPTARG requires an argument."`" "5"
;;
*)
exitScript "`echo "Option $OPTARG unrecognized."`" "5"
;;
esac
done
THX in advance.