Indent !
This body has no indentation, the next one has more than the previous.  There are blank lines between body lines and their opening braces, in some cases.  ISTR there's a style guide for these tests; but merely being consistent with yourself should suffice !
Some of these functions look like they should surely be in default.cf.sub; if they are, please don't reinvent the wheel in each test; if they aren't, consider putting them there, so as to use them from here and other tests.  This function, recurse, is only ever used once, with d = "inf" - why not just skip the parameter and set it to "inf" here ?