Skip to content
Joachim Ansorg edited this page Nov 12, 2021 · 4 revisions

Did you forget the then for this if?

Problematic code:

if true
  echo "foo"
elif true
  echo "bar"
fi

Correct code:

if true
then
  echo "foo"
elif true
then
  echo "bar"
fi

Rationale:

ShellCheck found a parsing error in the script, and determined that it's most likely due to a missing then keyword for the if or elif indicated.

Make sure the then is there.

Note that the then needs a ; or linefeed before it. if true then is invalid, while if true; then is correct.

Exceptions:

None

ShellCheck

Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature above to find a specific one, or see Checks.

Clone this wiki locally