]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix error when splicing Eshell globs and a glob expands to itself
authorJim Porter <jporterbugs@gmail.com>
Tue, 22 Oct 2024 16:43:00 +0000 (09:43 -0700)
committerEshel Yaron <me@eshelyaron.com>
Fri, 25 Oct 2024 05:05:34 +0000 (07:05 +0200)
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.

(cherry picked from commit b7a375f5c49ac86399b9af7a6a74720ed294abd7)

lisp/eshell/em-glob.el
test/lisp/eshell/em-glob-tests.el

index b95204c7e1e34eb46ed99045c4afdcb65c019bdd..42373b8b8c0ca254898bc3dadf076396ca1c2633 100644 (file)
@@ -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
index 2efb3a9df69703647823f2a951a0b566effd61dd..88e9cc73bbd5499e591bf42c3cf01b9384496582 100644 (file)
@@ -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