I have a shell script (/bin/sh) for backing up my subversion server in which I try to check the day of the month against a variable, but it fails on the 9th day of the month:
It failed today when assigning to DAYOFMONTH since today's date is the ninth of February.
sh(1) seems tells me under Arithmetic Expansion that octal constants start with 0, and I am supposing 09 doesn't compute.
I guess I could use string variables rather than arithmetic, but is there another way to solve this problem? Thanks.
- Thomas Backman
Code:
FORCE_BACKUP_ON_DAY=$((9))
FORCE_BACKUP="NO"
# ...
DAYOFMONTH=$((`date -j '+%d'`))
[ ${DAYOFMONTH} -eq ${FORCE_BACKUP_ON_DAY} ] && FORCE_BACKUP="YES"
It failed today when assigning to DAYOFMONTH since today's date is the ninth of February.
Code:
# echo `date -j '+%d'`
09
sh(1) seems tells me under Arithmetic Expansion that octal constants start with 0, and I am supposing 09 doesn't compute.
I guess I could use string variables rather than arithmetic, but is there another way to solve this problem? Thanks.
- Thomas Backman