Make your Bash scripts detect more errors, add this line early in a script:
`set -eu -o pipefail`
`set -e` makes the script fail if a command exits with a non-zero exit status.
`set -u` lets the script fail when you're trying to use not yet defined variables.
`set -o pipefail` will pass on the error from a failed piped command, e.g. `false | true` will then fail, where it would have succeeded otherwise. This one is not available in dash, but in busybox' ash it is.