Fix the escaping of the PATH

* Fixes "$PATH" so it'll work with spaces in it.
* Fixes added directories for the PATH, if it has characters that need
  to be quoted.
* Added test for add_pre_command

Closes: #392