Replace ~ with $HOME.