bug-bash
[Top][All Lists]
Advanced

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

Re: integer addition crash


From: Pierre Gaston
Subject: Re: integer addition crash
Date: Thu, 21 Jul 2011 09:47:28 +0300

On Wed, Jul 20, 2011 at 1:35 PM, Cédric Martínez Campos
<cedricmartinezcampos@gmail.com> wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-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 Asus-M50Vc 2.6.35-28-generic #50-Ubuntu SMP Fri
> Mar 18 18:42:20 UTC 2011 x86_64 GNU/Linux
> Machine Type: x86_64-pc-linux-gnu
>
> Bash Version: 4.1
> Patch Level: 5
> Release Status: release
>
> Description:
>        The integer addition $(($x+$y)) crashes if $x==08 or $x==09 (with a 
> leading 0).
>
> Repeat-By:
>        $ echo $((8+1))
>        9
>        $ echo $((9+1))
>        10
>        $ echo $((08+1))
>        bash: 08: too big element for the base (the error element is "08")

integer with a leading 0 are considered as octal by bash and 08 is not
valid in base 8.
you can force the base doing:
echo $((10#08+1))



reply via email to

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