Created SC1048 (markdown)

koalaman
2016-10-17 11:18:30 -07:00
parent ea08babac8
commit f85f61901a

29
SC1048.md Normal file

@@ -0,0 +1,29 @@
## Can't have empty then clauses (use 'true' as a no-op).
### Problematic code:
```sh
if [ -e foo ]
then
# TODO: handle this
fi
```
### Correct code:
```sh
if [ -e foo ]
then
# TODO: handle this
true
fi
```
### Rationale:
Shells do not allow empty `then` clauses. They need at least one command (and comments are not commands).
If you want a `then` clause that does nothing, use a dummy command like `true`.
### Exceptions:
None.