Handle :cd in external interpreter in a more robust way