Looks like that script could benefit from a couple of rounds of ShellCheck. http://www.shellcheck.net/
rm -rf "${FOO}/"
ShellCheck helpfully warned me that that could have disastrous consequences when FOO is unset, instead it advised me to use this: rm -rf "${FOO:?}/"
I'd also like to point out that ShellCheck is in the AUR for users of Arch Linux[0], and that there's a handy plugin which I use for the Atom editor[1].[0] https://github.com/SublimeLinter/SublimeLinter-shellcheck