Move directory cache setup to `setup` stage

The directory cache inserts some commands un-escaped from the config (mainly
when adding directories that should be cached). Instead of going through the
code and escaping them (I think they are unescaped so environment variables can
be used), I moved the directory cache setup to `setup`, which is after paranoid
mode is enabled, so these commands should be safe to run.
Shell escape all commands run before paranoid mode

In the case of the PostgreSQL command, the shell escaped code is taken outside
of the double quotes, since shell escaped code with Shellwords shouldn't be
placed inside of any quotes, single or double.