Subject: bug#53927: 27.2; shell-mode dir tracking falls out of sync after popd in remote buffers

From: Dan McCarthy <[email-masked]>
Date: Thu, 10 Feb 2022 15:18:46 -0500

Create a remote shell-mode buffer with C-u M-x shell, using bash as the
remote shell. pushd into another directory, then popd
back. default-directory and shell-dirstack still have the other
directory even though the popd took effect in the remote process.

The problem seems to be that shell-prefixed-directory-name returns a
string like "/ssh:dan@solstice:/ssh:dan@solstice:/home/dan/Documents/",
doubling the remote prefix.

Local shell-mode buffers do not have the problem.

In GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.18.9)
 of 2021-03-25 built on october
Windowing system distributor 'The X.Org Foundation', version 11.0.12014000
System Description: Slackware 15.0 x86_64

Recent messages:
Checking 113 files in /usr/local/share/emacs/27.2/lisp/obsolete...
Checking for load-path shadows...done
You can run the command ‘report-emacs-bug’ with M-x r-em RET
Checking for load-path shadows...done
Auto-saving...
Mark saved where search started
Making completion list...
nil
~/Documents ~/Documents
Making completion list...
("/ssh:dan@solstice:/home/dan/Documents/")
Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND GPM DBUS GSETTINGS GLIB NOTIFY INOTIFY
ACL GNUTLS LIBXML2 FREETYPE HARFBUZZ XFT ZLIB TOOLKIT_SCROLL_BARS GTK3
X11 XDBE XIM MODULES THREADS PDUMPER LCMS2 GMP

Important settings:
  value of $LC_COLLATE: C
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Shell

Minor modes in effect:
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  shell-dirtrack-mode: t
  hexl-follow-ascii: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tab-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
~/emacs-lisp/dictionary-el/link hides ~/.emacs.d/lisp/link
~/emacs-lisp/dictionary-el/connection hides ~/.emacs.d/lisp/connection
~/.emacs.d/lisp/android-mode hides
/home/blakestone/.emacs.d/elpa/android-mode-20140716.2347/android-mode
~/emacs-lisp/dictionary-el/dictionary hides
/home/blakestone/.emacs.d/elpa/dictionary-20201001.1727/dictionary
~/emacs-lisp/dictionary-el/dictionary-pkg hides
/home/blakestone/.emacs.d/elpa/dictionary-20201001.1727/dictionary-pkg
~/emacs-lisp/dictionary-el/connection hides
/home/blakestone/.emacs.d/elpa/connection-20191111.446/connection
~/emacs-lisp/dictionary-el/link hides
/home/blakestone/.emacs.d/elpa/link-20191111.446/link
~/.emacs.d/lisp/greek hides /usr/local/share/emacs/27.2/lisp/language/greek
~/.emacs.d/lisp/longlines hides
/usr/local/share/emacs/27.2/lisp/obsolete/longlines

Features:
(shadow sort mail-extr emacsbug sendmail debug ibuf-ext ibuffer
ibuffer-loaddefs loadhist edebug backtrace jka-compr eieio-opt speedbar
sb-image ezimage dframe make-mode c-eldoc cc-mode cc-fonts cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
magit-extras bug-reference magit-svn face-remap calc-undo calc-alg
calc-ext calc-menu calc calc-loaddefs calc-macs apropos cus-edit
wid-edit pcmpl-gnu vc-git reveal magit-submodule magit-obsolete
magit-blame magit-stash magit-reflog magit-bisect magit-push magit-pull
magit-fetch magit-clone magit-remote magit-commit magit-sequence
magit-notes magit-worktree magit-tag magit-merge magit-branch
magit-reset magit-files magit-refs magit-status magit magit-repos
magit-apply magit-wip magit-log which-func magit-diff smerge-mode diff
diff-mode git-commit log-edit easy-mmode message rmc puny rfc822 mml
mml-sec epa epg epg-config gnus-util rmail rmail-loaddefs
text-property-search mm-decode mm-bodies mm-encode mail-parse rfc2231
rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils
gmm-utils mailheader pcvs-util add-log magit-core magit-autorevert
autorevert filenotify magit-margin magit-transient magit-process
magit-mode transient magit-git magit-section magit-utils crm dash
sh-script smie pcmpl-unix mule-util diary-lib diary-loaddefs cal-menu
calendar cal-loaddefs with-editor tramp-cache tramp-sh tabify imenu man
pp cl-print mode-local find-func help-fns radix-tree iso-transl
executable grep rst dired dired-loaddefs misearch multi-isearch edmacro
kmacro paren cua-base cus-start cus-load acme-search quack thingatpt
compile cmuscheme scheme advice tramp tramp-loaddefs trampver
tramp-integration files-x tramp-compat shell pcomplete comint ring
parse-time iso8601 time-date ls-lisp format-spec ansi-color c-xref rx
session vanc-init bindat vanc-mode hexl ecf-mode derived cl-extra
help-mode dcm-general server cl android-mode-autoloads
go-eldoc-autoloads go-mode-autoloads sml-mode-autoloads
svg-clock-autoloads info package easymenu browse-url url-handlers
url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache json subr-x map url-vars seq byte-opt gv bytecomp
byte-compile cconv cl-loaddefs cl-lib tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads dbusbind inotify lcms2 dynamic-setting
system-font-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty make-network-process emacs)

Memory information:
((conses 16 407981 70581)
 (symbols 48 39873 4)
 (strings 32 146293 9854)
 (string-bytes 1 4078275)
 (vectors 16 49007)
 (vector-slots 8 1677838 74592)
 (floats 8 138 289)
 (intervals 56 43227 1568)
 (buffers 1000 57)
 (heap 1024 50828 7177))