If you are having trouble with a script that is excuting within a bundle, you can use the shell argument '-x' to turn on debugging for that script. You can do this by adding '-x' to the first line of the script as follows:
#!/bin/sh -x
Enabling debugging for a shell script can result in a lot of output, so it may be helpful to redirect standard out to a file using notation like '1>file.out'.