diff options
author | Michael Albinus <michael.albinus@gmx.de> | 2023-01-21 12:04:50 +0100 |
---|---|---|
committer | Michael Albinus <michael.albinus@gmx.de> | 2023-01-21 12:04:50 +0100 |
commit | b875c9bf67ebf858648a00307c370d7a196aab56 (patch) | |
tree | 2e87ba14f0d61696d90d916ace737d468e6d818f /lisp/net | |
parent | 63fa225d443409038e531fb9843e6d22a2efc94a (diff) | |
download | emacs-b875c9bf67ebf858648a00307c370d7a196aab56.tar.gz emacs-b875c9bf67ebf858648a00307c370d7a196aab56.tar.bz2 emacs-b875c9bf67ebf858648a00307c370d7a196aab56.zip |
Fix file-regular-p in Tramp
* test/lisp/net/tramp-archive-tests.el
(tramp-archive-test18-file-attributes)
(tramp-archive-test21-file-links):
* test/lisp/net/tramp-tests.el (tramp-test18-file-attributes)
(tramp-test21-file-links): Adapt tests.
* lisp/net/tramp.el (tramp-handle-file-regular-p): Fix symlink
case. (Bug#60943)
Diffstat (limited to 'lisp/net')
-rw-r--r-- | lisp/net/tramp.el | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index f0b17ef3934..123d01c747d 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -4031,9 +4031,15 @@ Let-bind it when necessary.") "Like `file-regular-p' for Tramp files." (and (file-exists-p filename) ;; Sometimes, `file-attributes' does not return a proper value - ;; even if `file-exists-p' does. - (when-let ((attr (file-attributes filename))) - (eq ?- (aref (file-attribute-modes attr) 0))))) + ;; even if `file-exists-p' does. Protect by `ignore-errors', + ;; because `file-truename' could raise an error for cyclic + ;; symlinks. + (ignore-errors + (when-let ((attr (file-attributes filename))) + (cond + ((eq ?- (aref (file-attribute-modes attr) 0))) + ((eq ?l (aref (file-attribute-modes attr) 0)) + (file-regular-p (file-truename filename)))))))) (defun tramp-handle-file-remote-p (filename &optional identification connected) "Like `file-remote-p' for Tramp files." |