From 730ea3922ae69f13eb659cf1db4553ff63d37a56 Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Thu, 31 Oct 2024 10:37:24 -0700 Subject: [PATCH] Don't remove trailing slash in Eshell "pwd" for remote root directories * lisp/eshell/em-dirs.el (eshell/pwd): Check if 'file-local-name' of the directory is the root dir. (cherry picked from commit 33997047e891d5513c4f33ab78ad353746ed16e2) --- lisp/eshell/em-dirs.el | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el index 9cf0994fe78..ad0a5beac1e 100644 --- a/lisp/eshell/em-dirs.el +++ b/lisp/eshell/em-dirs.el @@ -319,14 +319,13 @@ Thus, this does not include the current directory.") (defun eshell/pwd () "Change output from `pwd' to be cleaner." - (let* ((path default-directory) - (len (length path))) - (if (and (> len 1) - (eq (aref path (1- len)) ?/) - (not (and (eshell-under-windows-p) - (string-match "\\`[A-Za-z]:[\\/]\\'" path)))) - (setq path (substring path 0 (1- (length path))))) - (funcall (or eshell-pwd-convert-function #'identity) path))) + (let ((dir default-directory)) + (when (and (eq (aref dir (1- (length dir))) ?/) + (not (and (eshell-under-windows-p) + (string-match "\\`[A-Za-z]:[\\/]\\'" dir))) + (length> (file-local-name dir) 1)) + (setq dir (substring dir 0 -1))) + (funcall (or eshell-pwd-convert-function #'identity) dir))) (defun eshell-expand-multiple-dots (filename) ;; FIXME: This advice recommendation is rather odd: it's somewhat -- 2.39.5