Fix use of "dired" in Tramp
authorMichael Albinus <michael.albinus@gmx.de>
Sun, 21 Apr 2024 10:54:17 +0000 (12:54 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Sun, 21 Apr 2024 10:54:17 +0000 (12:54 +0200)
* lisp/net/tramp-sh.el (tramp-sh-handle-insert-directory): Do not
use "--dired" when long format output isn't requested.

lisp/net/tramp-sh.el

index 66e648624b298abb0a558106c1e6d4a992ee0c3d..60478707c2d4d7e92b30add4f3d3ef40571c6c67 100644 (file)
@@ -2653,6 +2653,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))))