while getopts "vr" n
do
case "$n" in
v) echo "Verbose" ;;
r) echo "Recursive" ;;
n) echo "Dry-run" ;;
*) usage;;
esac
donewhile getopts "vrn" n # 'n' added here
do
case "$n" in
v) echo "Verbose" ;;
r) echo "Recursive" ;;
n) echo "Dry-run" ;;
*) usage;;
esac
doneYou have a case statement in a
while getopts loop that matches a flag that hasn't been
provided in the getopts option string.
Either add the flag to the options list, or delete the case statement.
None.
ShellCheck is a static analysis tool for shell scripts. This page is part of its documentation.