Greg Wooledge wrote:

> On Sat, Feb 12, 2011 at 11:57:08AM +0100, Ralf Goertz wrote:
>> > 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?
> 
> s/not // in your question, I assume.

Actually, I was surprised that the $i version worked. Since I read this
group regularly I knew that the $((i)) version wouldn't work and so no,
the "not " is correct ;)
 
> If your i variable is coming from a source that may or may not include
> leading zeroes (such as date(1)) then you have two choices:
 
It does come from date(1) and I was prepared to run into problems due to
octal interpretation. When I didn't I tried to force the problem with
$((i)) which then made me wonder…

Thank you and the other responders.


Reply via email to