We frequently see jobs dying because of faulty scripts. This is part of a development cycle. After all: Who is perfect?
There are other ways than trying to correct the script post mortem - and saving time. One is to just check the syntax without executing a script:
$ bash -n scriptname
Another, very powerful tool is this on-line shell checker tool.