bug-bash
[Top][All Lists]
Advanced

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

Re: value too great for base (error token is "0008")


From: Bob Proulx
Subject: Re: value too great for base (error token is "0008")
Date: Tue, 3 Nov 2009 17:37:45 -0700
User-agent: Mutt/1.5.18 (2008-05-17)

Dobromir Romankiewicz wrote:
> And run this code:
> :2() { x1=0; x2=0; x3=0; x4=8
> echo $[$x1$x2$x3$x4]
> }
> It crashes with message:
> bash: 0008: value too great for base (error token is "0008").

Thank you for the report.  But you have run into Bash FAQ E8.

Numbers with leading zeros are read as octal constants.  Octal is
composed of '0' through '7'.  The number '8' is too large to be an
octal number.

  $ echo $((0008))
  bash: 0008: value too great for base (error token is "0008")

To have the number read as a decimal number the leading zeros must be
removed.

  $ echo $((8))
  8

Note also that the use of $[expression] for $((expression)) is
documented as deprecated and to be removed in a future version.
Better to use $((expression)) instead.

Bob




reply via email to

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