I've now bisected this bug, and the first bad commit is fc367 Since this is many years ago, I find it hard to believe that this file, MODULES.html.sh, had been broken for this long.
I will have to assume that Bash or sed on both FreeBSD and OS X is broken in some way.