Fix dired and tramp where ls does not have the -N option

This includes BSD ls, also used by macOS (bug#63142).

* lisp/dired.el (dired-insert-directory):
* lisp/net/tramp-sh.el (tramp-sh-handle-insert-directory):
Test whether -N is understood by ls since that option is used along
with --dired.  Remove -N when we remove --dired.
This commit is contained in:
Mattias Engdegård 2023-05-05 19:19:51 +02:00
parent f204c4a6cf
commit 778a1ee35b
2 changed files with 4 additions and 4 deletions

View file

@ -1647,9 +1647,9 @@ If HDR is non-nil, insert a header line with the directory name."
;; save the answer in `dired-use-ls-dired'.
(or (setq dired-use-ls-dired
(eq 0 (call-process insert-directory-program
nil nil nil "--dired")))
nil nil nil "--dired" "-N")))
(progn
(message "ls does not support --dired; \
(message "ls does not support --dired -N; \
see `dired-use-ls-dired' for more details.")
nil))
dired-use-ls-dired)))
@ -1665,7 +1665,7 @@ see `dired-use-ls-dired' for more details.")
;; "--dired", so we cannot add it to the `process-file'
;; call for wildcards.
(when (file-remote-p dir)
(setq switches (string-replace "--dired" "" switches)))
(setq switches (string-replace "--dired -N" "" switches)))
(let* ((default-directory (car dir-wildcard))
(script (format "ls %s %s" switches (cdr dir-wildcard)))
(remotep (file-remote-p dir))

View file

@ -2566,7 +2566,7 @@ The method used must be an out-of-band method."
(setq switches
(append switches (split-string (tramp-sh--quoting-style-options v))))
(unless (tramp-get-ls-command-with v "--dired")
(setq switches (delete "--dired" switches)))
(setq switches (delete "-N" (delete "--dired" switches))))
(when wildcard
(setq wildcard (tramp-run-real-handler
#'file-name-nondirectory (list localname)))