bug-bash
[Top][All Lists]
Advanced

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

Re: Strange bug in arithmetic function


From: jellybean stonerfish
Subject: Re: Strange bug in arithmetic function
Date: Tue, 22 Feb 2011 15:57:23 +0000 (UTC)
User-agent: Pan/0.132 (Waxed in Black)

On Mon, 21 Feb 2011 10:13:54 +0100, Marcel de Reuver wrote:

> In a bash script I use: $[`date --date='this week' +'%V'`%2] to see if
> the week number is even.
> Only in week 08 the error is: bash: 08: value too great for base (error
> token is "08") the same in week 09, all others are Ok...
> 
> GNU bash, version 3.2.39(1)-release (i486-pc-linux-gnu) Copyright (C)
> 2007 Free Software Foundation, Inc.
> 
> Running Ubutu 2.6.24-28 server

>From the bash manpage uhder ARITHMETIC EVALUATION
 "Constants with a leading 0 are interpreted as octal numbers."

The digits 8 and 9 are invalid.  Octal digits are 1,2,3,4,5,6,7,0

You can force base 10 by putting 10# before your numbers.



reply via email to

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