diff --git a/SC1048.md b/SC1048.md new file mode 100644 index 0000000..098b517 --- /dev/null +++ b/SC1048.md @@ -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. \ No newline at end of file