title: Bash script: too many arguments in [ test ]
body: <p>I have the bash script below:</p>
  
  <pre><code>#!/bin/bash
  #
  [ $# -eq 1 -a $1 = "--help" -o $# -eq 0 ] &amp;&amp; {
    echo Help will come here
  }
  </code></pre>
  
  <p>When I run it:</p>
  
  <pre><code>$ ./script 
  ./script: line 3: [: too many arguments
  $ ./script --help
  Help will come here
  </code></pre>
  
  <p>As you can see, when I don't pass parameters ( $# -eq 0 ) it fails with "too many arguments".
  So, I tested it directly in terminal:</p>
  
  <pre><code>$ a=1;b=2;c=3
  $ [ $a -eq 1 -a $b -eq 2 -o $c -eq 3 ] &amp;&amp; echo ok
  ok
  $ [ $a -eq 0 -a $b -eq 2 -o $c -eq 3 ] &amp;&amp; echo ok
  ok
  $ [ $a -eq 0 -a $b -eq 0 -o $c -eq 3 ] &amp;&amp; echo ok
  ok
  $ [ $a -eq 0 -a $b -eq 0 -o $c -eq 0 ] &amp;&amp; echo ok
  $ [ $a -eq 0 -a $b -eq 2 -o $c -eq 0 ] &amp;&amp; echo ok
  $ [ $a -eq 1 -a $b -eq 2 -o $c -eq 0 ] &amp;&amp; echo ok
  ok
  </code></pre>
  
  <p>So, if it works perfectly in terminal why doesn't it work passing parameters?</p>
  
  <p>Thanks,</p>