OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Subject: Re: 08 mis-parsed as octal?
From: Joseph S. Myers (jsm28cam.ac.uk)
Date: Sun May 14 2000 - 11:54:30 CDT


On Sun, 14 May 2000, Jim Dennis wrote:

> Expresssions like:
> echo $[ 08 + 0 ] and echo $(( 08 + 0 ))
>
> Give errors like:
> sh: 08: value too great for base (error token is "08")
>
> Though echo $[ 07 + 2 ] gives the expected result (9).
>
> This is inconsistent with earlier versions of bash as well as
> ksh (using the supported $(( ... )) syntax).

As already noted on security-audit: this behaviour is correct for the
shell - POSIX.2 Interpretation 173. Integer constants are to be handled
as in the C Standard, initial 0 means octal and 8 is not an octal digit.

http://www.pasc.org/interps/unofficial/db/p1003.2/pasc-1003.2-173.html

-- 
Joseph S. Myers
jsm28cam.ac.uk