title: Passing arguments to a function within an if statement in bash
body: <p>I am trying to pass arguments to a function within an <code>if</code> statement and then evaluating what the function returns (in bash).  The result I am getting is incorrect.  How do you properly do this?</p>
  <pre><code>#!/bin/bash
  
  foo() {
      if [ $1 = &quot;zero&quot; ]; then
          echo &quot;0&quot;
      else 
          echo &quot;1&quot;
  fi
  }
  
  arg=&quot;zero&quot;
  if foo $arg -eq 0 ; then
      echo &quot;entered 0&quot;
  else
      echo &quot;entered something else&quot;
  fi
  
  arg=&quot;blah&quot;
  if foo $arg -eq 0 ; then
      echo &quot;entered 0&quot;
  else
      echo &quot;entered something else&quot;
  fi
  </code></pre>
  <p>Not the desired results:</p>
  <pre><code>cknight@macbook:~/work$ ./test.sh
  0
  entered 0
  1
  entered 0
  </code></pre>