GNU bug report logs -
#66903
29.1; shell-mode directory tracking incorrectly handles double slashes
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
On Fri, Nov 3, 2023 at 5:07 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
> > From: Allen Li <darkfeline <at> felesatra.moe>
> > Date: Fri, 3 Nov 2023 03:43:35 -0700
> > Cc: 66903 <at> debbugs.gnu.org
> >
> > Currently, `cd ~//bin` will cause the shell (Bash or similar) to change
> to ~/bin, and Emacs/shell-mode
> > will change `default-directory` to `/bin`.
> >
> > This bug is saying that Emacs/shell-mode should change
> `default-directory` to `~/bin` by default,
>
> I think it should change default-directory to the directory to which
> the shell switches, not necessarily ~/bin.
>
That sounds different from what you're implying in your other emails.
Using sentences here is confusing.
The current behavior is:
Case 1
input: ~//bin
shell: ~/bin
default-directory: /bin
I'm suggesting
Case 2
input: ~//bin
shell: ~/bin
default-directory: ~/bin
When you say "I think it should change default-directory to the directory
to which
the shell switches, not necessarily ~/bin.", that implies to me Case 2
But your other emails suggest that you want:
Case 3
input: ~//bin (Emacs rewrites to /bin before sending to shell)
shell: /bin
default-directory: /bin
Assuming that you want Case 3, I think that is horrible for multiple
reasons. Firstly, a user would expect their shell to behave as in Case 2;
Case 3 is a surprising and semantically different rewrite of user input.
Furthermore, we would either have to rewrite all paths not just paths to
`cd`, which would be infeasible and error-prone, or surprise the user again
that Emacs is rewriting paths to `cd` specifically, but not, say, `rm` or
`mv` or many other commands (e.g., `mv ~//bin ~//lib`). Furthermore, the
only shell input rewriting that Emacs currently does is for history
substitutions, and the syntax for this is identical to common shells;
therefore, users can expect that Emacs does not do any surprising semantic
rewrites of their shell input. Case 3 would be violating this expectation.
For completeness, there is also
Case 4
input: ~//bin
shell: /bin (normal shell behavior)
default-directory: /bin
However, I am aware of zero shells in common use that behave like Case 4.
Even if we consider it, it should not be the default.
Also for completeness, there is a nuclear solution option, which is to
replace all of the cd, pushd, popd logic that shell-mode currently
implements and always run M-x dirs after every cd, pushd, popd command.
This naturally results in the behavior of Case 2, but also supports Case 4
for hypothetical shells that have said behavior.
[Message part 2 (text/html, inline)]
This bug report was last modified 1 year and 224 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.