title: simplify bash parameter verification with regexp
body: <p>I am writing a bash script and I am validating the input parameters that the user provides this way:</p>
  <pre><code>if [[ ($# -lt 1 || $# -gt 5)
      || ($# -eq 1 &amp;&amp; ! &quot;$1&quot; =~ ^(help|clean)$)
      || ($# -gt 1 &amp;&amp;
          (! &quot;$1&quot; =~ ^(build|clean|install|deploy|remove)$
              || ! &quot;$2&quot; =~ ^(|build|clean|install|deploy|remove)$
              || ! &quot;$3&quot; =~ ^(|build|clean|install|deploy|remove)$
              || ! &quot;$4&quot; =~ ^(|build|clean|install|deploy|remove)$
              || ! &quot;$5&quot; =~ ^(|build|clean|install|deploy|remove)$)) ]]; then
        show_help
        exit 1
  fi
  </code></pre>
  <p><strong>The validation rule is the following:</strong></p>
  <ul>
  <li>running without parameters is not allowed</li>
  <li>maximum 5 parameters are allowed</li>
  <li>if only one param is provided then it must be <code>help</code> or <code>clean</code>.</li>
  <li>if more than one parameters are provided then they must be one of the following: <code>build</code>, <code>clean</code>, <code>install</code>, <code>deploy</code>, <code>remove</code></li>
  </ul>
  <p>Is there any way to simplify the last 5 conditions and avoid the repetitions?</p>