title: How to write multiple if conditions ladder in a bash script?
body: <p>I am new to bash scripting, I wish to have if condition ladder<br>
  I am reading a string, based on which I want the correct if condition to be processed.<br></p>
  
  <p><strong>The logic is as follows -</strong></p>
  
  <p>If the string contains a substring <code>-deploy</code>, only then allow it to enter the if condition ladder.<br></p>
  
  <p>If the string contains both <code>-functions</code> and <code>-layer</code> substrings, then only my 1st if condition block needs to be called,<br></p>
  
  <p>elsif check for <code>-functions</code> substring<br></p>
  
  <p>elsif check for <code>-layer</code> substring<br></p>
  
  <p><strong>I've come up with the following code so far-</strong><br></p>
  
  <pre><code>commitMessage='[STABLE] -deploy -functions [one,two] -layer some commit message'
  
  if [[ ($commitMessage == *"deploy"* ) &amp;&amp; ($commitMessage == *"functions"*) || ($commitMessage == *"layer"*) ]] ; then
    if [[ ($commitMessage == *"functions"*) &amp;&amp; ($commitMessage == *"layer"*) ]] ; then
      echo 'functions and layer'
    fi
  
    elsif [[ $commitMessage == *"functions"* ]] ; then
      echo 'functions only'
    fi
  
    elsif [[ $commitMessage == *"layer"* ]] ; then
      echo 'layer only'
    fi
  fi
  </code></pre>
  
  <p><strong>I am getting a syntax error for elsif -</strong><br></p>
  
  <pre><code>syntax error near unexpected token `elif'
  </code></pre>
  
  <p><strong>I am referring this, but don't understand what I'm doing wrong -</strong><br>
  <a href="https://stackoverflow.com/questions/18974788/bash-if-multiple-conditions">Bash IF : multiple conditions</a></p>