Subject: bug#62096: 30.0.50; find-dired, dired-goto-file and spaces

From: Daniel Martín <[email-masked]>
Date: Sat, 11 Mar 2023 18:09:37 +0100

Manuel Giraud <[email-masked]> writes:

> Hi,
>
> So here is a patch that should fix *BSD and macOS.  For Windows, I don't
> know if it is the right fix (so it does nothing on Windows, sorry Drew).
>
> I choose "-dgils" because FreeBSD, NetBSD and macOS man pages state the
> following about -ls switch for find(1):
> The format is identical to that produced by "ls -dgils".
>
> On OpenBSD, the find(1) man page says:
> The format is identical to that produced by "ls -dils".
>
> But the "-g" switch does not seems to do something different when the
> "-l" is present.

This is what I see on macOS:

$ find . -name "*.jpg" -ls
93775284        0 -rw-r--r--    1 dmartin          staff                   0 Mar 10 18:33 ./we needed space.jpg

$ ls -dgils *.jpg
93775284 0 -rw-r--r--  1 staff  0 Mar 10 18:33 we needed space.jpg
$ ls -dils *.jpg
93775284 0 -rw-r--r--  1 dmartin  staff  0 Mar 10 18:33 we needed space.jpg

The -g switch seems to add/remove the group column, despite the man page
saying that the switch has no effect.

As you can see, the output of find -ls on macOS really seems to match
the output of ls -dils better, which is in concordance with the OpenBSD
documentation.

>
> For testing without recompiling Emacs, one could evaluate this:
>
> (setq find-ls-option-default-ls
>   (cons "-ls" (if (or (eq system-type 'berkeley-unix)
>                       (eq system-type 'darwin))
>                   "-dgils"
>                 "-dilsb")))
>
>
> Daniel: I'd like to hear what it does on macOS.
>

I've tested your patch and it seems to work fine on macOS.  However,
users can install GNU findutils on macOS, and in those systems the bug
would still be present.

Is there a more reliable way to discern between GNU find and other find
implementations, without checking the system-type?

I know the GNU version of find supports --version, while the macOS find
returns an error, but I don't know how reliable that check would be.