Subject: Re: bug#10586: 23.3; cd in remote shell reset working directory to local home

From: Alberto <[email-masked]>
Date: Wed, 25 Jan 2012 09:02:50 +0100

On 24 January 2012 19:19, Glenn Morris <[email-masked]> wrote:
> Alberto wrote:
>
>> Open a remote folder, e.g.
>>     C-x C-f /onan:bin
>> Open a remote shell there
>>     M-x shell
>> Check with pwd that working directory is remote
>>     M-x pwd
>> Execute in the shell cd
>>     > cd
>> Check with pwd that working directory is now _local_ home
>>     M-x pwd
>
> I can't reproduce this using Tramp's scpc method and don't see how such
> a thing could even be possible. Is your local home directory even
> visible on the remote machine?

I think there is a misunderstanding. Is not the bash shell that believes to
be in the local home.
But Emacs.
What happens is that the shell buffer lose synchronization  between the
current dir of the shell and the variable that emacs to keep track of it
(e.g. the one that is used to auto complete path in the shell).
So if you want, typing pwd in the _shell_ gives the correct result,
the remote home.
M-x pwd instead returns the wrong result (the local home instead of
something like
/onan:~)

> What tramp connection method are you
> using?
scpc
This is my default so in that particular connection is not shown explicitly.

Does it happen with `emacs -Q'?
Yes. It does. I run a separate test on a friend machine, the result is the same.
However I did a test with current emacs trunk (24.something).
On that one the problem cannot be reproduced.

>> After this happens the only way I found to fix the working directory
>> is to kill the shell buffer and open it again.
>
> Depending on the shell you use, does not 'cd -' take you back to the
> previous directory?
That was a good guess in fact, "cd -" gets emacs to go back to the remote home.
I've tried again using explicitly scpc. If it can help, emacs prints
the new folder as a message after every cd.
When I do the procedure above
 - for cd it is printed ~
 - for cd - it is printed /scpc:onan:bin

Hope it helps.
Regards

-- 
Alberto Ingenito