On Mon, Sep 12, 2011 at 04:45:28PM -0500, Abel Abraham Camarillo Ojeda wrote: > Some of our shell scripts that work with dates and do something like: > > month=`date +%m` > something && month=$((month-1)) > > Suddenly started crashing on august... there seems to be a bug identifying > not-numbers (numbers with leading zeroes) before '08' (eigth), how to > reproduce: > > $ for i in 0{0,1,2,3,4,5,6,7,8,9}; do a=$i; a=$((a-1)); echo $a; done > -1 > 0 > 1 > 2 > 3 > 4 > 5 > 6 > ksh: 08: bad number `08'
The string "08" can not be converted into a number for doing calculations. The 0 prefix signifies an octal number and 08 is not valid in the octal system. Bash will also tell you that this can not be done. Fix your script, add the leading zero after you're done with the calculation. > $ > > > Thanks.