bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: leading 0 inconsistence?


From: Ralf Goertz
Subject: Re: leading 0 inconsistence?
Date: Mon, 14 Feb 2011 15:12:38 +0100
User-agent: KNode/4.4.9

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

[Prev in Thread] Current Thread [Next in Thread]