From: Tino Calancha <tino.calancha@gmail.com>
Date: Wed, 2 Aug 2017 07:50:37 +0000 (+0900)
Subject: Don't assume /bin/sh as the 'sh' location in the local host
X-Git-Tag: emacs-26.0.90~517^2~45
X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e82c4f56e6f9a6bce4098698b17fa45dcc5bbd25;p=emacs.git

Don't assume /bin/sh as the 'sh' location in the local host

* lisp/dired.el (dired-insert-directory): Use executable-find in
a local host.
---

diff --git a/lisp/dired.el b/lisp/dired.el
index 4f8f615a34b..e1bedb6c73f 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -1276,12 +1276,17 @@ see `dired-use-ls-dired' for more details.")
              ;; call for wildcards.
              (when (file-remote-p dir)
                (setq switches (dired-replace-in-string "--dired" "" switches)))
-             (let ((default-directory (car dir-wildcard))
-                   (script (format "ls %s %s" switches (cdr dir-wildcard))))
+             (let* ((default-directory (car dir-wildcard))
+                    (script (format "ls %s %s" switches (cdr dir-wildcard)))
+                    (remotep (file-remote-p dir))
+                    (sh (or (and remotep "/bin/sh")
+                            (and (bound-and-true-p explicit-shell-file-name)
+                                 (executable-find explicit-shell-file-name))
+                            (executable-find "sh")))
+                    (switch (if remotep "-c" shell-command-switch)))
                (unless
                    (zerop
-                    (process-file
-                     "/bin/sh" nil (current-buffer) nil "-c" script))
+                    (process-file sh nil (current-buffer) nil switch script))
                  (user-error
                   "%s: No files matching wildcard" (cdr dir-wildcard)))
                (insert-directory-clean (point) switches)))