Expand variables in configuration files

e.g. $HOME. Fixes #6373.
Merge pull request #8309 from veeti/cfg-vars

Expand variables in configuration files