title: Shell script error: Syntax error: "(" unexpected (expecting "fi")
body: <p>I am getting a syntax error with the following shell script and I just can't figure out why:</p>
  
  <pre><code>./query_certs.sh: 22: ./query_certs.sh: Syntax error: "(" unexpected (expecting "fi")
  </code></pre>
  
  <p>Is it because of nested if-else statements?</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code># Check how many arguments we received
  if [ "$#" -gt 2 ]; then
      echo "Usage: $0 [MODE] DESTINATION_IP" &gt;&amp;2
      echo "MODE may be one of the following" &gt;&amp;2
      echo "none - shell script will ask interactively" &gt;&amp;2
      echo "HTTP - query the certificate from HTTPS (port 443)" &gt;&amp;2
      echo "LDAP - query the certificate from an AD  (port 636" &gt;&amp;2
      echo "FTP - query the certificate from an FTPs (ports 990/989)" &gt;&amp;2
      exit 1
  elif [ "$#" == 2 ]; then
      MODE=$1
      if [ "$MODE" == "HTTP" ]; then
          QUERY="foo"
      elif [ "$MODE" == "LDAP" ]; then
          QUERY="bar"
      elif [ "$MODE" == "FTP" ]; then
          QUERY="baz"
      else
          echo "Please choose a mode  (HTTP | LDAP | FTP):" # &lt;&lt;&lt; that's line 22
          options=("HTTP" "LDAP" "FTP";)
          select opt  in "${options[@]}" do
              case $opt in
                  "HTTP")
                      echo "Selected HTTP"
                      ;;
                  "LDAP")
                      echo "Selected LDAP"
                      ;;
                  "FTP")
                      echo "Selected FTP"
                      ;;
              esac
          done
      fi
  fi
  </code></pre>