Subject: bug#32588: 27.0.50; ‘default-directory’ not updated

From: Noam Postavsky <[email-masked]>
Date: Thu, 30 Aug 2018 07:18:26 -0400

tags 32588 notabug
close 32588
quit

Andreas Röhler <[email-masked]> writes:

> ‘default-directory’ not updated when dir was changed by a program
>
> Recipe from emacs -Q:
>
> M-x shell RET
> cd
> mkdir newdir
> echo "cd \$HOME/newdir/" > tonewdir
> chmod 700 tonewdir
> . tonewdir
> pwd
>
> ;;;
> `pwd` prints correctly result of $HOME/newdir
> while C-h v default-directory RET displays value of $HOME

(emacs) Directory Tracking:

    Shell mode keeps track of `cd', `pushd' and `popd' commands given to
    the subshell, in order to keep the Shell buffer's default directory
    (*note File Names::) the same as the shell's working directory.  It
    recognizes these commands by examining lines of input that you send.

       If you use aliases for these commands, you can tell Emacs to
    recognize them also, by setting the variables `shell-pushd-regexp',
    `shell-popd-regexp', and `shell-cd-regexp' to the appropriate regular
    expressions (*note Regexps::).

       If Emacs gets confused about changes in the working directory of the
    subshell, type `M-x dirs'.