I found that &#x27;shell&#x27; mode occasionally got confused, for instance on what the current directory is. I have changed to &#x27;eshell&#x27; as my primary shell emulator, one that implements a number of the basic commands directly in elisp. It works quite well, except when running an interactive command which is does not handle well and there are some issues with piping as well.