Bad substitution sounds like there may be an issue with the shell you're using. Perhaps you should try a different one. You might also consider running a full installation of Windows with something like Qemu.
That's about all the advice I can offer.
Thank you Guy.
I expect you are write that the problem is that it was written for /bin/sh and I was using /bin/bash. What I did find is that if I commented out any if statements that utilized "==" comparators, it worked just fine. I get it -- that is a bit hacky, but in the near term, it seems to work. Honestly, I didn't think enough about it to run it using sh instead of bash...
Again, thank you.