Subject: Re: bug#49918: 28.0.50; cd function expands CDPATH incorrectly

From: Lars Ingebrigtsen <[email-masked]>
Date: Sat, 07 Aug 2021 12:51:22 +0200

Phil Hagelberg <[email-masked]> writes:

> When using the function `cd' with a relative path and the $CDPATH
> environment variable set, it will expand the value of $CDPATH once and
> save off that expansion for future use. This causes all calls with
> relative paths to fail when run from a different directory.
>
> This reproduces the problem using eshell, but the bug affects any caller
> of the `cd' function, not just eshell. However, it does not affect M-x
> cd, which will always use absolute paths.
>
>     CDPATH=.:$HOME/src emacs -Q
>     M-x eshell
>     cd /
>     cd tmp
>     No such directory found via CDPATH environment variable: tmp
>
> This happens because of this snippet inside the `cd' function:
>
>     (unless cd-path
>       (setq cd-path (or (parse-colon-path (getenv "CDPATH"))
>                         (list "./"))))

Yup.  Thanks for the detailed analysis.

This should now be fixed in Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no