From 93da7a202d8fc23cd3af064eb94adbb1c9c0944f Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen <larsi@gnus.org> Date: Sat, 5 Feb 2022 23:57:38 +0100 Subject: [PATCH] Tweak how eshell/cd works when cd-ing to ".." from "/" * lisp/eshell/em-dirs.el (eshell/cd): Make "cd .." from "/" less confusing (bug#16861). --- lisp/eshell/em-dirs.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el index 893cad7b4fb..3998026d7f4 100644 --- a/lisp/eshell/em-dirs.el +++ b/lisp/eshell/em-dirs.el @@ -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) -- 2.39.5