Skip to content
Vidar Holen edited this page Apr 28, 2018 · 1 revision

Use elif to start another branch.

Problematic code:

if false
then
  echo "hi"
elseif true
then
  echo "ho"
fi

Correct code:

if false
then
  echo "hi"
elif true
then
  echo "ho"
fi

Rationale:

ShellCheck noticed that you appear to be using elseif or elsif as a keyword. This is not valid.

sh instead uses elif as its alternative branch keyword.

Exceptions:

If you have made your own function called elseif and intend to call it, you can ignore this message.

Related resources:

  • Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!

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