I currently have a script that is using short flags -M
, -m
, and -b
. I only want to make use of one argument, so I just have it break on the matching flag. I would like to change it so that it returns a non-zero code if more than one flag is used, and I'd like to support long flags (--major
, --minor
, --bug
). How can I modify this block of code I use now to achieve that?
while getopts ":Mmb" increment; do
case "${increment}" in
M)
result=1
break
;;
m)
result=2
break
;;
b)
result=3
break
;;
esac
done