Subject: bug#63142: 30.0.50; QUOTING_STYLE can break dired

From: Eli Zaretskii <[email-masked]>
Date: Fri, 05 May 2023 14:25:18 +0300

> From: Mattias Engdegård <[email-masked]>
> Date: Fri, 5 May 2023 13:04:56 +0200
> Cc: Michael Albinus <[email-masked]>,
>  Yuri D'Elia <[email-masked]>,
>  [email-masked],
>  [email-masked]
> 
> This change breaks tramp-tests on MacOS (and, I presume, BSDs) where `ls` accepts neither `--dired` nor `-N`. see appended test log.

Sorry, I don't understand.  The change added -N only where we
previously had --dired in the 'ls' switches.  Are you saying that we
somehow now pass "--dired -N" where previously we didn't pass "--dired"?

AFAIU, we should use --dired only when 'ls' supports it, and we now
use -N under the same conditions.  Is that not what happens?

> In fact even ls-lisp doesn't seem to accept `-N`, or at least do anything with it. Not sure if that is a problem or not.

This should not be used when ls-lisp is in use, see the line
emphasized below:

    (if (and
	 ;; Don't try to invoke `ls' if we are on DOS/Windows where
	 ;; ls-lisp emulation is used, except if they want to use `ls'
	 ;; as indicated by `ls-lisp-use-insert-directory-program'.
	 (not (and (featurep 'ls-lisp)  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
		   (null ls-lisp-use-insert-directory-program)))
         ;; FIXME: Big ugly hack for Eshell's eshell-ls-use-in-dired.
         (not (bound-and-true-p eshell-ls-use-in-dired))
	 (or (file-remote-p dir)
             (if (eq dired-use-ls-dired 'unspecified)
		 ;; Check whether "ls --dired" gives exit code 0, and
		 ;; 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")))
		     (progn
		       (message "ls does not support --dired; \
see `dired-use-ls-dired' for more details.")
		       nil))
	       dired-use-ls-dired)))
        ;; Use -N with --dired, to countermand possible non-default
        ;; quoting style, in particular via the environment variable
        ;; QUOTING_STYLE.
	(setq switches (concat "--dired -N " switches)))

So once again, I don't understand what you are saying.  In any case,
I've just tried "C-x d" on MS-Windows, where ls-lisp is used by
default, and saw no problems.  What am I missing?

> Should we reopen this bug or open a new one?

I'd like Michael to chime in first.