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

2009-11-03 Thread Bob Proulx
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




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

2009-11-03 Thread Dobromir Romankiewicz
Configuration Information [Automatically generated, do not change]:
Machine: i486
OS: linux-gnu
Compiler: gcc
Compilation 
CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' -DCONF_OSTYPE='linux-gnu' 
-DCONF_MACHTYPE='i486-pc-linux-gnu' -DCONF_VENDOR='pc' 
-DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  
-I../bash -I../bash/include -I../bash/lib   -g -O2 -Wall
uname output: Linux debian 2.6.26-2-686 #1 SMP Wed Aug 19 06:06:52 UTC 2009 
i686 GNU/Linux
Machine Type: i486-pc-linux-gnu

Bash Version: 3.2
Patch Level: 39
Release Status: release

Description:
[
Well... Just paste those functions into your text konsole, and compare to my 
results:

:1() { x1=0; x2=0; x3=0; x4=7
echo $[$x1$x2$x3$x4]
}
The result is 7.

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").

:3() { x1=0; x2=0; x3=0; x4=8
echo $[$x4$x2$x3$x1]
}
works well, printing 8000.

Similar codes
:4() { x1=0; x2=0; x3=0; x4=8
s=$x1$x2$x3$x4
echo $[$s]
}
or
:5() { x1=0; x2=0; x3=0; x4=8
s=$x1$x2$x3$x4
echo $[s]
}
goes the same way like :2
Oh, if x4=9 it goes the same way as if x4=8. I didn't check higher values.
]


signature.asc
Description: This is a digitally signed message part.