Consider using shellcheck + linter in your ide
Created by: edge226
I use Atom editor. It has a neat plugin system that allows linter + shellcheck to automatically lint your code.
Running find ./ -type f -name '*.sh' -exec shellcheck {} + > shellcheck
I was able to produce this file with all of your errors + warnings mixed in together.
If you have shellcheck installed then it shows you red lines for errors and orange lines for warnings.
I've attached a file with all of the warnings and errors based on your scripts.