Variable assignment in Unix : <p>When I try following statements, it doesn't assign values properly to variables and loop goes infinite- </p>

<pre><code>while ( [ $nos -ne 0 ] )
do
    rem = `expr $nos % 10`
    sum = `expr $sum + $rem`
    nos = `expr $nos / 10`
done
</code></pre>

<p>But when I remove spaces from left and right side of assignment operator, it works fine. Like this - </p>

<pre><code>while ( [ $nos -ne 0 ] )
do
    rem=`expr $nos % 10`
    sum=`expr $sum + $rem`
    nos=`expr $nos / 10`
done
</code></pre>

<p>Why the Shell behaviour is like that?</p>
