From 9a6fc638433c19021278616019ef5064740f86fe Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sat, 7 Aug 2021 12:50:56 +0200 Subject: [PATCH] Fix problem with relative directories in CDPATH * lisp/files.el (parse-colon-path): Allow relative directories (like ".") in CDPATH (bug#49918). --- lisp/files.el | 5 ++++- test/lisp/files-tests.el | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index c2607956915..b58f90db48c 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -782,7 +782,10 @@ nil (meaning `default-directory') as the associated list element." (let ((spath (substitute-env-vars search-path))) (mapcar (lambda (f) (if (equal "" f) nil - (let ((dir (expand-file-name (file-name-as-directory f)))) + (let ((dir (file-name-as-directory f))) + (when (file-name-absolute-p dir) + ;; Expand "~". + (setq dir (expand-file-name dir))) ;; Previous implementation used `substitute-in-file-name' ;; which collapse multiple "/" in front. Do the same for ;; backward compatibility. diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index 640f7d8420e..523f51e0194 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el @@ -1461,7 +1461,10 @@ See ." (should (equal (parse-colon-path "x:/foo//bar/baz") '("x:/foo/bar/baz/"))) (should (equal (parse-colon-path "/foo//bar/baz") - '("/foo/bar/baz/"))))) + '("/foo/bar/baz/")))) + + (should (equal (parse-colon-path ".:/tmp") + '("./" "/tmp/")))) (ert-deftest files-test-magic-mode-alist-doctype () "Test that DOCTYPE and variants put files in mhtml-mode." -- 2.39.2