Writing Robust Bash Shell Scripts
davidpashley.com
davidpashley.com
It is a static analyzer for Shell, that looks for some of the problems cited in the post.
There is also a little overlap with this "unofficial bash strict mode," which I now use all the time:
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
--- http://redsymbol.net/articles/unofficial-bash-strict-mode/You can only fool yourself that multiple unrelated operations to the filesystem will be atomic. A more pragmatic approach is to clean up everything at the beginning of the script and start the actual operations with that assumption (and checking the exit status of every command). If the script is interrupted in the middle, just start it again.
I would add that you should use an explicit shebang such as #!/bin/bash instead of #!/bin/sh if your script is anything more complicated than a simple list of statements.