]> git.eshelyaron.com Git - emacs.git/commitdiff
Tweak how eshell/cd works when cd-ing to ".." from "/"
authorLars Ingebrigtsen <larsi@gnus.org>
Sat, 5 Feb 2022 22:57:38 +0000 (23:57 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Sat, 5 Feb 2022 22:57:38 +0000 (23:57 +0100)
* lisp/eshell/em-dirs.el (eshell/cd): Make "cd .." from "/" less
confusing (bug#16861).

lisp/eshell/em-dirs.el

index 893cad7b4fb218356eeb4a9c4333caa6cb3c3cea..3998026d7f4e7933176eeaf0f3fd0e7a6848c9fa 100644 (file)
@@ -391,6 +391,10 @@ in the minibuffer:
        (unless (equal curdir newdir)
          (eshell-add-to-dir-ring curdir))
        (let ((result (cd newdir)))
+          ;; If we're in "/" and cd to ".." or the like, make things
+          ;; less confusing by changing "/.." to "/".
+          (when (equal (file-truename result) "/")
+            (setq result (cd "/")))
          (and eshell-cd-shows-directory
               (eshell-printn result)))
        (run-hooks 'eshell-directory-change-hook)