emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 604eb02: Make subprocess functions resolve the defa


From: Philipp Stephani
Subject: [Emacs-diffs] master 604eb02: Make subprocess functions resolve the default directory
Date: Tue, 4 Apr 2017 08:33:54 -0400 (EDT)

branch: master
commit 604eb02fff061e663e7523f45a72ecb71c2061e1
Author: Philipp Stephani <address@hidden>
Commit: Philipp Stephani <address@hidden>

    Make subprocess functions resolve the default directory
    
    `call-process' doesn't respect file name handlers in
    `default-directory', so `file-name-non-special' has to resolve them
    for `process-file', `start-file-process', and
    `shell-command' (Bug#25949).
    
    * lisp/files.el (file-name-non-special): Also resolve default
    directory for 'process-file', 'start-file-process', and
    'shell-command'.
    * test/lisp/files-tests.el
    (files-tests--file-name-non-special--subprocess): Add unit test.
---
 lisp/files.el            | 10 +++++++++-
 test/lisp/files-tests.el |  8 ++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/lisp/files.el b/lisp/files.el
index b4872e4..204c264 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -6915,7 +6915,15 @@ only these files will be asked to be saved."
 (defun file-name-non-special (operation &rest arguments)
   (let ((file-name-handler-alist nil)
        (default-directory
-         (if (eq operation 'insert-directory)
+          ;; Some operations respect file name handlers in
+          ;; `default-directory'.  Because core function like
+          ;; `call-process' don't care about file name handlers in
+          ;; `default-directory', we here have to resolve the
+          ;; directory into a local one.  For `process-file',
+          ;; `start-file-process', and `shell-command', this fixes
+          ;; Bug#25949.
+         (if (memq operation '(insert-directory process-file start-file-process
+                                                 shell-command))
              (directory-file-name
               (expand-file-name
                (unhandled-file-name-directory default-directory)))
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index 9d456c5..80bbeb1 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -243,5 +243,13 @@ be $HOME."
                          (concat "/:/:" subdir)))))
       (delete-directory dir 'recursive))))
 
+(ert-deftest files-tests--file-name-non-special--subprocess ()
+  "Check that Bug#25949 is fixed."
+  (skip-unless (executable-find "true"))
+  (should (eq (let ((default-directory "/:/")) (process-file "true")) 0))
+  (should (processp (let ((default-directory "/:/"))
+                      (start-file-process "foo" nil "true"))))
+  (should (eq (let ((default-directory "/:/")) (shell-command "true")) 0)))
+
 (provide 'files-tests)
 ;;; files-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]