shell style fix

Fixes for shell coding style and for potential errors with space in `$HOME` etc.

This should work but it is completely untested. Please check on real mac if it works ok.