A better debugger for your Bash scripts: http://bashdb.sourceforge.net/. Actually, it replaces Bash, so if your script was particularly strange, you might exhibit a problem when it runs under bash but not bashdb or vice versa.
That would probably be a pretty rare circumstance though.. and I can tell you that I have wanted to single-step through a shell script more than once, not because the script was broken but just because I wanted to control it more easily than messing it up with additional "read junk" lines. So maybe this is worth taking a look at it.
Got something to add? Send me email.
Increase ad revenue 50-250% with Ezoic
Inexpensive and informative Apple related e-books:
Sierra: A Take Control Crash Course
Take Control of iCloud
Take Control of Upgrading to Yosemite
Photos: A Take Control Crash Course
Take Control of the Mac Command Line with Terminal, Second Edition