diff options
author | Jim Porter <jporterbugs@gmail.com> | 2024-05-05 13:09:08 -0700 |
---|---|---|
committer | Jim Porter <jporterbugs@gmail.com> | 2024-05-05 13:21:55 -0700 |
commit | 1529ad0315f8d4a96ca07969c1c91c1c50bb6075 (patch) | |
tree | 71a648b495d91485b4ca26c91ee3a4d98ce5dfa8 /lisp/eshell | |
parent | 451863adf942bf4e3c1b9346c0f37e546e16b1fd (diff) | |
download | emacs-1529ad0315f8d4a96ca07969c1c91c1c50bb6075.tar.gz |
Fix Eshell handling of remote files like "/ssh:remote:~/file.txt"
* lisp/eshell/em-glob.el (eshell-glob-convert): Use 'concat' instead of
'file-name-concat' to avoid extraneous slashes.
(eshell-extended-glob): Bail out if we didn't find a glob after all.
* test/lisp/eshell/em-glob-tests.el (tramp): Require.
(em-glob-test/convert/remote-start-directory): Use the mock remote
connection.
(em-glob-test/remote-user-directory): New test.
Diffstat (limited to 'lisp/eshell')
-rw-r--r-- | lisp/eshell/em-glob.el | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/lisp/eshell/em-glob.el b/lisp/eshell/em-glob.el index 7fc6958a00f..89a40151d00 100644 --- a/lisp/eshell/em-glob.el +++ b/lisp/eshell/em-glob.el @@ -317,7 +317,7 @@ The result is a list of three elements: result) ;; We haven't seen a glob yet, so instead append to the start ;; directory. - (setq start-dir (file-name-concat start-dir (car globs)))) + (setq start-dir (concat start-dir (car globs)))) (setq last-saw-recursion nil)) (setq globs (cdr globs))) (list start-dir @@ -341,16 +341,24 @@ Mainly they are not supported because file matching is done with Emacs regular expressions, and these cannot support the above constructs." (let ((globs (eshell-glob-convert glob)) eshell-glob-matches message-shown) - (unwind-protect - (apply #'eshell-glob-entries globs) - (if message-shown - (message nil))) - (or (and eshell-glob-matches (sort eshell-glob-matches #'string<)) - (if eshell-error-if-no-glob - (error "No matches found: %s" glob) - (if eshell-glob-splice-results - (list glob) - glob))))) + (if (null (cadr globs)) + ;; If, after examining GLOB, there are no actual globs, just + ;; bail out. This can happen for remote file names using "~", + ;; like "/ssh:remote:~/file.txt". During parsing, we can't + ;; 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 + (unwind-protect + (apply #'eshell-glob-entries globs) + (if message-shown + (message nil))) + (or (and eshell-glob-matches (sort eshell-glob-matches #'string<)) + (if eshell-error-if-no-glob + (error "No matches found: %s" glob) + (if eshell-glob-splice-results + (list glob) + glob)))))) ;; FIXME does this really need to abuse eshell-glob-matches, message-shown? (defun eshell-glob-entries (path globs only-dirs) |