Subject: Re: bug#66903: 29.1; shell-mode directory tracking incorrectly handles double slashes

From: Stefan Kangas <[email-masked]>
Date: Fri, 3 Nov 2023 17:21:11 -0700

Eli Zaretskii <[email-masked]> writes:

>> From: Eshel Yaron <[email-masked]>
>> Cc: [email-masked],  [email-masked]
>> Date: Fri, 03 Nov 2023 13:35:46 +0100
>>
>> Eli Zaretskii <[email-masked]> writes:
>>
>> >> I just wanted to note that this is not really an option with M-x shell,
>> >> because it is the shell, and not Emacs, that interprets "cd" and changes
>> >> directory.
>> >
>> > You assume that shell.el must send everything the user types verbatim
>> > to the shell?
>>
>> No, not "must" and not "everything", but if you think about it
>> intercepting "cd" and altering its argument would make `M-x shell`
>> incompatible with other shell interfaces, breaking valid command lines
>> in weird ways.  Does that make sense?
>
> It does to me.  To understand why, start Emacs in your HOME directory,
> and then type this:
>
>   M-x cd RET ~//bin RET

It would be highly dangerous to start mangling command lines to shells
run under `M-x shell' in incompatible ways.  Not to mention that such a
change would be backwards-incompatible.  Consider the command

    sudo rm -rf ~//usr

This is not a contrived example, BTW, but more or less exactly a command
I have run in the last year.  I don't think I used //, but double
slashes are always collapsed in POSIX, so I can't be sure.  It's not
something I look for that when cobbling together shell commands in
POSIX-compatible shells (bash and zsh here).

So I think we should not do that.