mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-08 15:35:02 +00:00
Fix error when splicing Eshell globs and a glob expands to itself
This could happen when 'eshell-extended-glob' determines that a "glob" is not really a glob. This mainly happens for remote file names with a "~" in them, like "/ssh:remote:~/file.txt". * lisp/eshell/em-glob.el (eshell-extended-glob): Return a list when 'eshell-glob-splice-results' is non-nil. * test/lisp/eshell/em-glob-tests.el (em-glob-test/expand/splice-results) em-glob-test/expand/no-splice-results): Extend tests.
This commit is contained in:
parent
2289e16226
commit
b7a375f5c4
@ -348,7 +348,7 @@ regular expressions, and these cannot support the above constructs."
|
||||
;; always be sure if the "~" is a home directory reference or
|
||||
;; part of a glob (e.g. if the argument was assembled from
|
||||
;; variables).
|
||||
glob
|
||||
(if eshell-glob-splice-results (list glob) glob)
|
||||
(unwind-protect
|
||||
(apply #'eshell-glob-entries globs)
|
||||
(if message-shown
|
||||
|
@ -74,7 +74,13 @@ component ending in \"symlink\" is treated as a symbolic link."
|
||||
;; Ensure the default expansion splices the glob.
|
||||
(eshell-command-result-equal "funcall list *.el" '("a.el" "b.el"))
|
||||
(eshell-command-result-equal "funcall list *.txt" '("c.txt"))
|
||||
(eshell-command-result-equal "funcall list *.no" '("*.no")))))
|
||||
;; When spliting, no-matches cases also return a list containing
|
||||
;; the original non-matching glob.
|
||||
(eshell-command-result-equal "funcall list *.no" '("*.no"))
|
||||
(when (eshell-tests-remote-accessible-p)
|
||||
(let ((remote (file-remote-p ert-remote-temporary-file-directory)))
|
||||
(eshell-command-result-equal (format "funcall list %s~/a.el" remote)
|
||||
`(,(format "%s~/a.el" remote))))))))
|
||||
|
||||
(ert-deftest em-glob-test/expand/no-splice-results ()
|
||||
"Test that globs are treated as lists when
|
||||
@ -85,9 +91,13 @@ component ending in \"symlink\" is treated as a symbolic link."
|
||||
;; Ensure the default expansion splices the glob.
|
||||
(eshell-command-result-equal "funcall list *.el" '(("a.el" "b.el")))
|
||||
(eshell-command-result-equal "funcall list *.txt" '(("c.txt")))
|
||||
;; The no-matches case is special here: the glob is just the
|
||||
;; The no-matches cases are special here: the glob is just the
|
||||
;; string, not the list of results.
|
||||
(eshell-command-result-equal "funcall list *.no" '("*.no")))))
|
||||
(eshell-command-result-equal "funcall list *.no" '("*.no"))
|
||||
(when (eshell-tests-remote-accessible-p)
|
||||
(let ((remote (file-remote-p ert-remote-temporary-file-directory)))
|
||||
(eshell-command-result-equal (format "funcall list %s~/a.el" remote)
|
||||
`(,(format "%s~/a.el" remote))))))))
|
||||
|
||||
(ert-deftest em-glob-test/expand/explicitly-splice-results ()
|
||||
"Test explicitly splicing globs works the same no matter the
|
||||
|
Loading…
Reference in New Issue
Block a user