Table of Contents
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
break
is only valid in loops
Problematic code:
case "$1" in
-v)
verbose=1
break
;;
-d)
debug=1
esac
Correct code:
case "$1" in
-v)
verbose=1
;;
-d)
debug=1
esac
Rationale:
break
or continue
was found outside a loop. These statements are valid only in loops. In particular, break
is not required in case
statements as there is no implicit fall-through.
To return from a function or sourced script, use return
. To exit a script, use exit
.
Exceptions:
It's possible to break
/continue
in a function without a loop. The call will then affect the loop – if any – that the function is invoked from, but this is obviously not good coding practice.
-
Installation
-
Usage
-
Integrating and extending
Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature above to find a specific one, or see Checks.