Pattern: Unhandled getopts
flag
Issue: -
You have a while getopts
loop where the corresponding case
statement fails to handle one of the flags.
Either add a case to handle the flag, or remove it from the getopts
option string.
Example of incorrect code:
while getopts "vrn" n
do
case "$n" in
v) echo "Verbose" ;;
r) echo "Recursive" ;;
*) usage;;
esac
done
Example of correct code:
while getopts "vrn" n
do
case "$n" in
v) echo "Verbose" ;;
r) echo "Recursive" ;;
n) echo "Dry-run" ;; # -n handled here
*) usage;;
esac
done