title: Bash - While loop doesn't stop
body: <p>I've written a script where I have a while loop. I've tried two similar looking conditions but for some weird reason one of the condition works but the other doesn't.</p>
  <p>Works, the loop stops as expected.</p>
  <pre><code>function finder {
      # it prints an integer
  }
  
  for ((current = 1; current &lt;= $total_lines; current++)); do
      foo=$(( current - 1 ))
      while [ &quot;$(finder $foo)&quot; = &quot;0&quot; ]; do
          (( foo-- ))
      done
  done
  </code></pre>
  <p>Doesn't work, the while loop never stops.</p>
  <pre><code>function finder {
      # it prints an integer
  }
  
  for ((current = 1; current &lt;= $total_lines; current++)); do
      foo=$(( current - 1 ))
      while [[ $(finder $foo) -eq 0 ]]; do
          (( foo-- ))
      done
  done
  </code></pre>
  <p>My actual question is what are the differences between these conditions? I want the 2nd condition to work somehow.</p>
  <pre><code>while [ &quot;$(finder $foo)&quot; = &quot;0&quot; ];
  # versus
  while [[ $(finder $foo) -eq 0 ]];
  </code></pre>