Subject: bug#53739: 28.0.91; "C-x d" fails when "emacs -Q" starts on NetBSD with plan9/bin on head of PATH

From: Van Ly <[email-masked]>
Date: Sat, 5 Feb 2022 03:07:07 +0000 (UTC)

On Fri, 4 Feb 2022, Eli Zaretskii wrote:

                     Please step through the code of insert-directory
> and describe here what you see there when it reports the error.
> Everything else is just noise, as far as investigation of this problem
> is concerned.

Using Edebug on the instrumented insert-directory function narrows in
on lisp/files.el
'''
  7502                     (apply 'call-process
  7503                            insert-directory-program nil t nil
  7504                            (append
  7505                             (if (listp switches) switches
  7506                               (unless (equal switches "")
  7507                                 ;; Split the switches at any spaces so we can
  7508                                 ;; pass separate options as separate args .
  7509                                 (split-string-and-unquote switches)))
  7510                             ;; Avoid lossage if FILE starts with `-'.
  7511                             '("--")
  7512                             (list file))))))
'''

The "result" exit status is "1" on line 7512 closing parenthesises.

The call is "ls -al -- /usr/X" and the problem is Plan's ls doesn't
take the "-a" switch.  For example

'''
% ls -a
usage: ls [-dlmnpqrstuFQ] [file ...]
% echo $?
1
% ls -al
usage: ls [-dlmnpqrstuFQ] [file ...]
% echo $?
1
'''

The Edebug steps continue to line 7581.

lisp/files.el:7581
"Listing directory failed but `access-file' worked"

In the case of Plan9's ls what is needed is to leave out the "-a" switch.

-- 
vl