On Monday 21 Feb 2011 09:13:54 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...
It's not a bug. First, you shouldn't use the ancient and deprecated $[ .. ] syntax for arithmetic evaluation; use $(( .. )). Second, bash interprets numbers with leading zeros as octal, thus "08" isn't a valid octal number. You can force it to be interpreted as decimal by prepending the base, eg see $ echo $(( 08 + 2 )) -su: 08: value too great for base (error token is "08") $ echo $(( 10#08 + 2 )) 10 -- D.