Don't add an extraneous slash in remote PATH list in Eshell

Previously, in a remote directory, '(eshell-get-path)' would return a
list of strings like "/ssh:localhost://usr/bin".  While that shouldn't
break most things, it's not strictly correct either.  See bug#65551.

* lisp/eshell/esh-util.el (eshell-get-path): Use 'concat' instead of
'file-name-concat'.

* test/lisp/eshell/esh-util-tests.el: Require 'tramp' and
'eshell-tests-helpers'.
(esh-util-test/path/get, eshell-util-test/path/get-remote): New tests.
This commit is contained in:
Jim Porter 2023-08-27 12:49:25 -07:00
parent 34f7a47c9c
commit bc0426ce8e
2 changed files with 31 additions and 1 deletions

View file

@ -283,7 +283,7 @@ as the $PATH was actually specified."
(eshell-under-windows-p))
(push "." path))
(if (and remote (not literal-p))
(mapcar (lambda (x) (file-name-concat remote x)) path)
(mapcar (lambda (x) (concat remote x)) path)
path))))
(defun eshell-set-path (path)

View file

@ -19,9 +19,15 @@
;;; Code:
(require 'tramp)
(require 'ert)
(require 'esh-util)
(require 'eshell-tests-helpers
(expand-file-name "eshell-tests-helpers"
(file-name-directory (or load-file-name
default-directory))))
;;; Tests:
(ert-deftest esh-util-test/eshell-stringify/string ()
@ -54,4 +60,28 @@
"Test that `eshell-stringify' correctly stringifies complex objects."
(should (equal (eshell-stringify (list 'quote 'hello)) "'hello")))
(ert-deftest esh-util-test/path/get ()
"Test that getting the Eshell path returns the expected results."
(let ((expected-path (butlast (exec-path))))
(should (equal (eshell-get-path)
(if (eshell-under-windows-p)
(cons "." expected-path)
expected-path)))
(should (equal (eshell-get-path 'literal)
expected-path))))
(ert-deftest esh-util-test/path/get-remote ()
"Test that getting the remote Eshell path returns the expected results."
(let* ((default-directory ert-remote-temporary-file-directory)
(expected-path (butlast (exec-path))))
;; Make sure we don't have a doubled directory separator.
(should (seq-every-p (lambda (i) (not (string-match-p "//" i)))
(eshell-get-path)))
(should (equal (eshell-get-path)
(mapcar (lambda (i)
(concat (file-remote-p default-directory) i))
expected-path)))
(should (equal (eshell-get-path 'literal)
expected-path))))
;;; esh-util-tests.el ends here