Here is a snippet:
for arg in "$@"; do
if [ $arg == "--coverage" ]; then
ENABLE_COVERAGE=1
shift
elif [ $arg == "--mysql" ]; then
MYSQL_ONLY=1
shift
elif [ $arg == "--psql" ]; then
PSQL_ONLY=1
shift
elif [ $arg == "-h" ] || [ $arg == "--help" ]; then
usage
shift
elif [ $arg == "--qa" ]; then
QA_ONLY=1
PSQL_ONLY=1
MYSQL_ONLY=1
shift
elif [ $arg == "--qa" ] && [ $arg == "--mysql" ]; then
QA_ONLY=1
MYSQL_ONLY=1
shift
elif [ $arg == "--qa" ] && [ $arg == "--psql" ]; then
QA_ONLY=1
PSQL_ONLY=1
shift
elif [ $arg == "--" ]; then
shift
break
fi
done
If you can call getopt in bash, you can’t call getopt, it shouldn’t use long option name. use getopts instead of getopt.(below is a example)