I'm trying to figure out a way to deny the usage of more than one getopts args in a certain situation. Say we have something like this:
while getopts "a:b:c:def" variable; do
case $variable in
a)a=$OPTARG
b)b=$OPTARG
c)c=$OPTARG
d)MODE=SMTH
e)MODE=SMTH2
f)MODE=SMTH3
esac
done
What im trying to do is to deny the use of more than one MODE arg (def) and display a message to tell that to the user. Something in the line of:
./script.sh -a ajhsd -b kjdhas -c daskjdha -d -e -f
performs check for use of more than one MODE arg(def) and if more than one is used displays an error message. I tried with a simple input check if statement but failed miserably. It always passes through all three and obtains the last passed argument parameter without even going inside the multiple args check. Kind of weird. It should've been easy to do this. Should have...