Skip to content

Files

Latest commit

 

History

History
42 lines (30 loc) · 756 Bytes

SC1089.md

File metadata and controls

42 lines (30 loc) · 756 Bytes

Pattern: Incorrect use of Bash keyword

Issue: -

Description

This error is typically seen when there are too many fi, done or esacs, or when there's a do or then without a corresponding while, for or if. This is often due to deleting a loop or conditional statement but not its terminator.

In some cases, it can even be caused by bad quoting:

var="foo
if [[ $var = "bar ]
then
  echo true
fi

In this case, the if ends up inside the double quotes, leaving the then dangling.

Example of incorrect code:

if true
then
  echo hello
fi
fi

Example of correct code:

if true
then
  echo hello
fi

Further Reading