Fix re-entrance issue in .bashrc/.profile