On 12 Feb 2011, at 11:57, Ralf Goertz wrote:
>
> Hi,
>
> I am wondering what the reasoning might be for this seeming
> inconsistence.
>
>> i=08
>> if [ $i -lt 9 ] ; then echo ok; fi
> ok
>> if [ $((i)) -lt 9 ] ; then echo ok; fi
> bash: 08: value too great for base (error token is "08")
>
> Why is 08 not tried to be interpreted as octal when *numerically* compared
> using test?
>
>
I stand by my general recommendation of always using (( when performing
arithmetic tests, [[ when testing strings and files, and never [, unless your
shebang is not actually bash. It will save you from a great many pitfalls and
inconsistencies.