On 09/12/2011 05:45 PM, 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'
$
Seems like it's being interpreted as an octal number because of the
leading zero. ksh93 on Linux does not interpret this as octal and
runs the snippet fine. bash on linux does interpret it as octal and
gives a similar error.
/bin/ksh on OpenBSD 4.5 gives the same error so it is not a recent
behavior change in OpenBSD.
- Aner