Alexey Knyazev wrote:
> k...@fish-eye:~$ if (( 06 > 06 )); then echo lazhaa; fi
> k...@fish-eye:~$ if (( 07 > 06 )); then echo lazhaa; fi
> lazhaa
> k...@fish-eye:~$ if (( 07 > 07 )); then echo lazhaa; fi
> k...@fish-eye:~$ if (( 08 > 07 )); then echo lazhaa; fi
> bash: ((: 08: value too great for base (error token is "08")
> k...@fish-eye:~$ if (( 09 > 08 )); then echo lazhaa; fi
> bash: ((: 09: value too great for base (error token is "09")
> k...@fish-eye:~$

If you accept that the expressions in the non-standard construct ((FOO))
work the same as the ones in the standard construct $((FOO)), which
seems reasonable, then this is perfectly correct behaviour. Arithmetic
expressions recognize hexadecimal (starting with 0x), octal (starting
with 0) or decimal (starting with 1-9) numbers. Another example: the
following expression is true:
  (( 8 == 010 ))

The numerical comparisons -lt, -le, -eq, -ne, -ge, -gt in test and [
recognize only decimal numbers. Therefore 09 is valid and nine and 010
is ten and not eight.

I will admit that this is messy, but I think changing it now will only
create a bigger mess. POSIX says where octal numbers shall and shall not
be recognized and software generally complies to that.

-- 
Jilles Tjoelker



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to