cleanup shell coding

* use double-brackets `[[ ... ]]` because they are a builtin function, instead of starting a separate `test` process
* proper quoting of paths and filenames in conditions, `cd`, `rm`, ...
* whitespace stuff
  * indentation normalised to 2 spaces across all (bash) files
  * newline after shebang and after initial comment block