Shell

Shell

Made by DeepSource

Mismatched keyword SH-1089

Bug risk
Critical

This error is typically seen when there are too many fis, dones or esacs , or when there's a do or then without a corresponding while, for or if.

Problematic code:

if true
then
  echo hello
fi
fi

Preferred code:

if true
then
  echo hello
fi

This often happens 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.