From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Phil Hagelberg Newsgroups: gmane.emacs.bugs Subject: bug#49918: 28.0.50; cd function expands CDPATH incorrectly Date: Fri, 06 Aug 2021 18:18:10 -0700 Message-ID: <87lf5eyrvx.fsf@hagelb.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9738"; mail-complaints-to="usenet@ciao.gmane.io" To: 49918@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 07 03:19:16 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mCAza-0002L3-Iq for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 07 Aug 2021 03:19:15 +0200 Original-Received: from localhost ([::1]:57308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mCAzY-0005Wj-JA for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 06 Aug 2021 21:19:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCAzQ-0005WW-MZ for bug-gnu-emacs@gnu.org; Fri, 06 Aug 2021 21:19:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40057) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mCAzO-00067u-SD for bug-gnu-emacs@gnu.org; Fri, 06 Aug 2021 21:19:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mCAzN-0004xy-Sh for bug-gnu-emacs@gnu.org; Fri, 06 Aug 2021 21:19:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Phil Hagelberg Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 07 Aug 2021 01:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 49918 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.162829910819043 (code B ref -1); Sat, 07 Aug 2021 01:19:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 7 Aug 2021 01:18:28 +0000 Original-Received: from localhost ([127.0.0.1]:51603 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCAyp-0004x5-IC for submit@debbugs.gnu.org; Fri, 06 Aug 2021 21:18:28 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:44802) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCAyn-0004wu-1c for submit@debbugs.gnu.org; Fri, 06 Aug 2021 21:18:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCAym-0005VV-PY for bug-gnu-emacs@gnu.org; Fri, 06 Aug 2021 21:18:24 -0400 Original-Received: from eastern.birch.relay.mailchannels.net ([23.83.209.55]:30129) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCAyk-0005fq-FO for bug-gnu-emacs@gnu.org; Fri, 06 Aug 2021 21:18:24 -0400 X-Sender-Id: dreamhost|x-authsender|phil@hagelb.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id E61A85425B8 for ; Sat, 7 Aug 2021 01:18:18 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a56.g.dreamhost.com (100-96-17-214.trex-nlb.outbound.svc.cluster.local [100.96.17.214]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 7CAE0542584 for ; Sat, 7 Aug 2021 01:18:17 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|phil@hagelb.org Original-Received: from pdx1-sub0-mail-a56.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.17.214 (trex/6.3.3); Sat, 07 Aug 2021 01:18:18 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|phil@hagelb.org X-MailChannels-Auth-Id: dreamhost X-Suffer-Ski: 49423c624f05c467_1628299098708_3181500846 X-MC-Loop-Signature: 1628299098708:3901683677 X-MC-Ingress-Time: 1628299098708 Original-Received: from pdx1-sub0-mail-a56.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a56.g.dreamhost.com (Postfix) with ESMTP id BD68C7EF7F for ; Fri, 6 Aug 2021 18:18:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=hagelb.org; h=from:to :subject:date:message-id:mime-version:content-type; s= hagelb.org; bh=IsduMuRBiab4x0iKD7hP96O6erk=; b=GXQ7aUBkE5KcsL6yN ksh5oHtqRgP/cS1d2YI2ZeKdBuuPNxpGkinqokL8rjAjnyrC1gWGEqzSGlCjyfD1 q575qFHyT0Lg723kit7y20n/SL+Z4OGvNOhsaaIn0ZAqyF9NgpGaQNOTEedp+oZx VLT7XyxnLdSC0KTwQS9w7q44dI= Original-Received: from reform (174-21-73-225.tukw.qwest.net [174.21.73.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: phil@hagelb.org) by pdx1-sub0-mail-a56.g.dreamhost.com (Postfix) with ESMTPSA id 927B27F1FA for ; Fri, 6 Aug 2021 18:18:16 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a56 Received-SPF: pass client-ip=23.83.209.55; envelope-from=phil@hagelb.org; helo=eastern.birch.relay.mailchannels.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:211356 Archived-At: 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 "./")))) The behavior of the `parse-colon-path' function changed in 2020 in commit 76098d39c992aa51f5bdb04fb39e40fc5eb409d5: - (mapcar (lambda (f) - (if (equal "" f) nil - (substitute-in-file-name (file-name-as-directory f)))) - (split-string search-path path-separator)))) + (let ((spath (substitute-env-vars search-path))) + (mapcar (lambda (f) + (if (equal "" f) nil + (let ((dir (expand-file-name (file-name-as-directory f)))) + ;; Previous implementation used `substitute-in-file-name' + ;; which collapse multiple "/" in front. Do the same for + ;; backward compatibility. + (if (string-match "\\`/+" dir) + (substring dir (1- (match-end 0))) dir)))) + (split-string spath path-separator))))) Previous behavior did not expand relative paths like "." but the new behavior does. That means that the above call which sets cd-path cannot use this function as is. Either the old behavior of parse-colon-path will need to be brought back, or `cd' needs to no longer call that function. Witness on the current master branch: ($PWD here is ~/src/emacs) (parse-colon-path ".:/hey") : -> ("/home/phil/src/emacs/" "/hey/") Whereas on 27, you get this: (parse-colon-path ".:/hey") : -> ("./" "/hey/") The old behavior is safe to set for the value of `cd-path' but the new behavior is not. In GNU Emacs 28.0.50 (build 1, aarch64-unknown-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0) of 2021-08-06 built on reform Repository revision: 0b049fe71d73f6885a3c81ea31829e3befc18933 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12099001 System Description: Debian GNU/Linux 11 (bullseye) Configured using: 'configure --with-cairo --with-modules --without-compress-install --with-gnutls --without-gconf --without-xaw3d --without-gsettings --with-mailutils --with-native-compilation --with-json --with-harfbuzz --without-imagemagick --with-jpeg --with-png --with-rsvg --with-tiff --with-wide-int --with-xft --with-xml2 --with-xpm 'CFLAGS=-O3 -mtune=native -march=native -fomit-frame-pointer' prefix=/usr/local' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Diff Minor modes in effect: recentf-mode: t whitespace-mode: t global-company-mode: t company-mode: t shell-dirtrack-mode: t winner-mode: t show-paren-mode: t save-place-mode: t tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t buffer-read-only: t column-number-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: ~/.emacs.d//phil/../custom hides /home/phil/src/emacs/lisp/custom Features: (shadow sort mail-extr emacsbug message rmc dired dired-loaddefs rfc822 mml mml-sec epa derived epg epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail hippie-exp sh-script executable smerge-mode diff flyspell ispell mhtml-mode css-mode smie eww xdg url-queue shr kinsoku svg xml browse-url puny mm-url gnus nnheader gnus-util rmail rmail-loaddefs rfc2047 rfc2045 ietf-drums mail-utils mm-util mail-prsvr js cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs sgml-mode facemenu dom scpaste htmlize url url-proxy url-privacy url-expand url-methods url-history url-cookie url-domsuf url-util url-parse auth-source password-cache json map url-vars mailcap cl-print pulse color xref project eieio eieio-core eieio-loaddefs ielm pp tabify vc-annotate imenu hi-lock misearch multi-isearch add-log log-view pcvs-util vc vc-git diff-mode easy-mmode vc-dispatcher bug-reference find-func shortdoc text-property-search em-tramp em-xtra help-fns radix-tree recentf tree-widget wid-edit pcmpl-unix time-date paredit whitespace idle-highlight-mode thingatpt hl-line company-dabbrev-code company-dabbrev company-files company-capf company pcase em-unix em-term term disp-table shell ehelp em-script em-prompt em-ls em-hist em-pred em-glob em-dirs esh-var em-cmpl pcomplete comint ansi-color em-basic em-banner em-alias esh-mode eshell esh-cmd esh-ext esh-opt esh-proc esh-io esh-arg esh-module esh-groups esh-util winner ring smex comp comp-cstr warnings subr-x rx cl-seq cl-macs cl-extra help-mode advice my-autoload paren edmacro kmacro cl-loaddefs cl-lib saveplace ido seq byte-opt gv bytecomp byte-compile cconv iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty make-network-process native-compile emacs) Memory information: ((conses 16 348427 19451) (symbols 48 19549 1) (strings 32 73704 4571) (string-bytes 1 2519167) (vectors 16 37842) (vector-slots 8 705331 23605) (floats 8 380 691) (intervals 56 21516 4320) (buffers 992 29))