From 80c7ce91cc0a35542ba485cf8cb5bc6dabac0169 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sun, 21 Apr 2024 12:54:17 +0200 Subject: [PATCH] Fix use of "dired" in Tramp * lisp/net/tramp-sh.el (tramp-sh-handle-insert-directory): Do not use "--dired" when long format output isn't requested. (cherry picked from commit 9c01da56a547f493535e73877e16ccefcb2730a0) --- lisp/net/tramp-sh.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 046b83b0a49..5af1d723bb9 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -2662,6 +2662,18 @@ The method used must be an out-of-band method." (let ((dired (tramp-get-ls-command-with v "--dired"))) (when (stringp switches) (setq switches (split-string switches))) + ;; Newer coreutil versions of ls (9.5 and up) imply long format + ;; output when "--dired" is given. Suppress this implicit rule. + (when dired + (let ((tem switches) + case-fold-search) + (catch 'long + (while tem + (when (and (not (string-match-p "--" (car tem))) + (string-match-p "l" (car tem))) + (throw 'long nil)) + (setq tem (cdr tem))) + (setq dired nil)))) (setq switches (append switches (split-string (tramp-sh--quoting-style-options v)) (when dired `(,dired)))) -- 2.39.5