Skip to content

Files

Latest commit

 

History

History
37 lines (28 loc) · 604 Bytes

SC1048.md

File metadata and controls

37 lines (28 loc) · 604 Bytes

Pattern: Empty then clause

Issue: -

Description

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.

Example of incorrect code:

if [ -e foo ]
then
  # TODO: handle this
fi

Example of correct code:

if [ -e foo ]
then
  # TODO: handle this
  true
fi

# Or use the no-op colon operator ":"
if [ -e foo ]
then
  # TODO: handle this
  :
fi

Further Reading