Updating bash syntax

- Use Posix $() instead of backticks
- Use double brackets instead of single. Double brackets are syntax
  whereas single backticks are commands; doubles are faster. Double
  brackets deal with cases where variables evaluate to the empty string
  on either side of the expression. This means they're safer. They also
  allow boolean && || expressions and as used elsewhere in the code
  regex matches.
- A few whitespace fixes.