title: I encountered "unary operator expected" in a Bash script
body: <p>In my Bash script, I have a function to return 0 or 1 (true or false) for the later <em>main</em> function's condition.</p>
  <pre><code>function1 () {
      if [[ &quot;${1}&quot; =~ &quot;^ ...some regexp... $&quot; ]] ; then
          return 1
      else
          return 0
      fi
  }
  </code></pre>
  <p>Then in my <em>main</em> function:</p>
  <pre><code>main () {
      for arg in ${@} ; do
          if [ function1 ${arg} ] ; then
              ...
          elif [ ... ] ; then
              ...
          fi
      done
  }
  </code></pre>
  <p>However, when I ran this script it always gave me an error message:</p>
  <blockquote>
  <p>[: function1: unary operator expected</p>
  </blockquote>
  <p>How can I fix this?</p>