christoph ender's

blog

friday the 1st of august, 2025

the august problem

Starting August 1st, I got some 08: value too great for base scripts errors in my logs. Turned out I got the current month number in a bash script using date +%m, which was then evaluated in tests using conditions like [[ ${VAR} -eq 1 ]].

I wrote this a few months before and up until today things were running without any problem. On August 1st, however, date +%m for the first time evaluated to 08 – including the leading zero since I used the %m modifier. Without any modifiers, bash will interpret values having leading zeroes as octal values. That wasn't a problem since up until the end of July, 07 was equal to decimal 7, stating August 1st however, 08 evaluated to an invalid octual value.

While one can simply strip leading zeroes using sed or other replacement methods, it's also possible to tell bash explicitely to interpret values using base 10 using a 10# prefix:

if [[ 10#${VAR} -eq 1 ]]; then echo yes; fi