Expand variables in configuration files

e.g. $HOME. Fixes #6373.