mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC1049 (markdown)
32
SC1049.md
Normal file
32
SC1049.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
## Did you forget the 'then' for this 'if'?
|
||||||
|
|
||||||
|
### Problematic code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
if true
|
||||||
|
echo "foo"
|
||||||
|
elif true
|
||||||
|
echo "bar"
|
||||||
|
fi
|
||||||
|
```
|
||||||
|
|
||||||
|
### Correct code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
if true
|
||||||
|
then
|
||||||
|
echo "foo"
|
||||||
|
elif true
|
||||||
|
then
|
||||||
|
echo "bar"
|
||||||
|
fi```
|
||||||
|
|
||||||
|
### Rationale:
|
||||||
|
|
||||||
|
ShellCheck found a parsing error in the script, and determined that it's most likely due to a missing `then` keyword for the `if` or `elif` indicated.
|
||||||
|
|
||||||
|
Make sure the `then` is there. It needs `;` or linefeed before it (e.g. `if true; then`, not `if true then`).
|
||||||
|
|
||||||
|
### Exceptions:
|
||||||
|
|
||||||
|
None
|
Reference in New Issue
Block a user