title: for loop in bash exiting to early without errors
body: <p>Why doesn't my for loop: for ((i=1 ;i&lt;=$n, i++)) work? I can not figure this out. when n is for example 4, the line <code>echo $n</code> returns 4 but it does not go into the loop again. I don't get any errors either. I tried to make a small loop like: </p>
  
  <pre><code>for ((i=1, i&lt;=$n; i++)); do 
      echo "this works" 
  done
  </code></pre>
  
  <p>This works fine which makes it even stranger to me :/. Thanks in advance</p>
  
  <pre><code>read n
  length=16
  p=()
  p[1]=50
  rest=63
  function s() {
      arr=($@)
      line="_____________________________________________________________________"
      for i in ${arr[@]}; do
          line=$( echo $line |  sed s/./1/$i)
      done
      echo $line
  }
  for ((i=1; i&lt;=$n; i++)); do
      echo $n
      for ((j=1; j&lt;=$length; j++)); do
          s ${p[@]}
      done
      len=${#p[@]}
      ((len=$len*2))
      for ((k=1; k&lt;=$len; k+=2)); do
          ((p[$k+1]=p[$k]+1))
          ((p[$k]=p[$k]-1))
      done
      for ((l=1; l&lt;=$length; l++)); do
          s ${p[@]}
          len=${#p[@]}
          for ((m=1; m&lt;=$len; m+=2)); do
              ((p[$m+1]=p[$m+1]+1))
              ((p[$m]=p[$m]-1))
          done
      done
      ((rest=$rest-2*$length))
      ((length=$length/2))
  done
  </code></pre>