if [ $thisVar -eq $thatVar ] then // processing fi
if [ -eq 5 ] then...
What does this mean? It means the shell is looking for a variable and found nothing. Not an empty variable, nothing. Take this structure:
If one of the variables is empty, the shell wips out the old unary operator expected
error which can be a fault tollerant but can mess up the flow.
The reason this happens is because the arguments were not quoted. This is a common pitfall excpecially for those comming from more structured languages. Re-examining the above example, lets say thisVar
was empty and thatVar
was 5; what the shell sees is:
This situation can be avoided with a set of quotes. If bot variables were quoted the tables would be turned because the shell would see... if [ -eq 5
] then...
and the old unary operator expected
would never be thrown.