title: bash function return in if statement not working
body: <p>I'm trying to refactor this code:</p>
  
  <pre><code>if [ $(($1 % 4)) -eq 0 ] &amp;&amp; [ $(($1 % 100)) -ne 0 ] || [ $(($1 % 400)) -eq 0 ] ; then
      echo $T
  else
      echo $F
  fi
  </code></pre>
  
  <p>into something like this:</p>
  
  <pre><code>if divisibleBy4 &amp;&amp; notDivisibleBy100 || divisibleBy400; then
      echo $T
  else
      echo $F
  fi
  </code></pre>
  
  <p>note that </p>
  
  <pre><code>T="true"
  F="false"
  </code></pre>
  
  <p>divisibleBy4 function looks like:</p>
  
  <pre><code>divisibleBy4() {
      return  [ $(($1 % 4)) -eq 0 ]
  }
  </code></pre>
  
  <p>But I've tried several iterations including what I thought would definitely work. </p>
  
  <pre><code>divisibleBy4() {
      if [ $(($1 % 4)) -eq 0  ]; then
      return 1
      else return 0
      fi
  }
  </code></pre>
  
  <p>Any idea how to properly fix the syntax so I can refactor these into functions and use them in my if statement? </p>
  
  <p>When testing I'm seeing the error</p>
  
  <blockquote>
    <p>syntax error: operand expected (error token is "% 4")</p>
  </blockquote>
  
  <p>Another thing I tried is, but still doesn't seem to work:</p>
  
  <pre><code>INPUT=$1
  
  divisibleBy4() {
      if [ $(($INPUT % 4)) -eq 0  ]; then
           return 1
      else return 0
      fi
  }
  
  notDivisibleBy100() {
      if [ $(($INPUT % 100)) -ne 0]; then
           return 1
      else return 0
      fi
  }
  
  divisibleBy400() {
      if [ $(($INPUT % 400)) -eq 0  ]; then
           return 1
      else return 0
      fi
  }
  
  
  if divisibleBy4 &amp;&amp; notDivisibleBy100 || divisibleBy400; then
      echo $T
  else
      echo $F
  fi
  </code></pre>
  
  <p>or</p>
  
  <pre><code>INPUT=$1
  
  divisibleBy4() {
      return $((!($INPUT %4)))
  }
  notDivisibleBy100() {
      return $(($INPUT %100))
  }
  divisibleBy400() {
      return $((!($INPUT %400)))
  }
  
  (( divisibleBy4 &amp;&amp; notDivisibleBy100 || divisibleBy400 )) &amp;&amp; echo "true" || echo "false"
  </code></pre>