The following ksh88 code takes values for month [m] and year [y] and works out the previous month [p_m], and year of the previous month [p_m_y]. m is originally derived from date command and so has a leading zero if current month < 10. m=02y=2017if [ $((m-1)) -gt 1 ]then    p_m=$((m-1))    p_m_y=$((y))else    p_m=12    p_m_y=$((y-1))fiIn this example p_m is being set to 12, and p_m_y is 2016, so the if statement seems failing and always triggering the 'else' code.... even where m is greater than 1. I think the leading zero may be the issue? The same thing happens if I use [[ .. ]]. If I amend it to the below, it worksif [[ $((m-1)) != 01 ]]Presumably this now a string comparison, the arithmetic comparison is not working.  not a huge issue, I could still work with this. But there should be a way to get it work using proper arithmetic.  If I try and force base10 expansion, it does not have any effect. if [[ $((10#$m-1)) -gt 1 ]]
test with arithmetic expansion (leading zero)
ksh
The issue in the specific example you show is not that m has a leading zero  even if it were treated as octal, 02 is still just 2.  The test you are using is:[ $((m-1)) -gt 1 ]But m-1 > 1 is equivalent to m > 2.  Since 2 is not greater than 2, the else clause will be run.  You can change the test to simply[ $m -gt 1 ]But it would be far simpler to just use the shell's arithmetic capabilities directly:m=02y=2017p_m=$(( (m+10)%12 + 1 ))p_m_y=$(( y - (m==1) ))That last bit probably merits some explanation:For p_m, we use modular arithmetic.  (m + 10)%12 is equivalent to two months prior (or ten months later), except that December is listed as 0.  We then add one to achieve the previous month, in the range 112.The last line is simpler.  (m==1) is either 1 if m is numerically equal to 1, else 0.  So p_m_y is set to the current year if m is not 1, else the previous year.As an aside, you say:m is originally derived from the date command and so has a leading zero if current month < 10.This is not necessarily the case.  On my system:$ date2017  5  9  13:58:53 EDT$ LC_ALL=en_US.UTF-8 dateTue May  9 13:58:53 EDT 2017$ date '+%Y %m %d' | sed 's/ 0*/ /g'2017 5 9So if you are concerned about numbers being interpreted as octal, you may want to try this last one.