From: Lars Ingebrigtsen Date: Sat, 5 Feb 2022 22:57:38 +0000 (+0100) Subject: Tweak how eshell/cd works when cd-ing to ".." from "/" X-Git-Tag: emacs-29.0.90~2502 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=93da7a202d8fc23cd3af064eb94adbb1c9c0944f;p=emacs.git Tweak how eshell/cd works when cd-ing to ".." from "/" * lisp/eshell/em-dirs.el (eshell/cd): Make "cd .." from "/" less confusing (bug#16861). --- 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)