diff options
| author | Philipp Stephani | 2017-03-03 17:56:01 +0100 |
|---|---|---|
| committer | Philipp Stephani | 2017-04-04 14:32:01 +0200 |
| commit | 604eb02fff061e663e7523f45a72ecb71c2061e1 (patch) | |
| tree | b9328e9f9f6df7e82509de8ed207a8ea03716cf6 | |
| parent | f4b50dad8d5eade04f495c693c0bca46060b25cb (diff) | |
| download | emacs-604eb02fff061e663e7523f45a72ecb71c2061e1.tar.gz emacs-604eb02fff061e663e7523f45a72ecb71c2061e1.zip | |
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.
| -rw-r--r-- | lisp/files.el | 10 | ||||
| -rw-r--r-- | test/lisp/files-tests.el | 8 |
2 files changed, 17 insertions, 1 deletions
diff --git a/lisp/files.el b/lisp/files.el index b4872e46b01..204c26416a6 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -6915,7 +6915,15 @@ only these files will be asked to be saved." | |||
| 6915 | (defun file-name-non-special (operation &rest arguments) | 6915 | (defun file-name-non-special (operation &rest arguments) |
| 6916 | (let ((file-name-handler-alist nil) | 6916 | (let ((file-name-handler-alist nil) |
| 6917 | (default-directory | 6917 | (default-directory |
| 6918 | (if (eq operation 'insert-directory) | 6918 | ;; Some operations respect file name handlers in |
| 6919 | ;; `default-directory'. Because core function like | ||
| 6920 | ;; `call-process' don't care about file name handlers in | ||
| 6921 | ;; `default-directory', we here have to resolve the | ||
| 6922 | ;; directory into a local one. For `process-file', | ||
| 6923 | ;; `start-file-process', and `shell-command', this fixes | ||
| 6924 | ;; Bug#25949. | ||
| 6925 | (if (memq operation '(insert-directory process-file start-file-process | ||
| 6926 | shell-command)) | ||
| 6919 | (directory-file-name | 6927 | (directory-file-name |
| 6920 | (expand-file-name | 6928 | (expand-file-name |
| 6921 | (unhandled-file-name-directory default-directory))) | 6929 | (unhandled-file-name-directory default-directory))) |
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index 9d456c512b0..80bbeb1bc54 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el | |||
| @@ -243,5 +243,13 @@ be $HOME." | |||
| 243 | (concat "/:/:" subdir))))) | 243 | (concat "/:/:" subdir))))) |
| 244 | (delete-directory dir 'recursive)))) | 244 | (delete-directory dir 'recursive)))) |
| 245 | 245 | ||
| 246 | (ert-deftest files-tests--file-name-non-special--subprocess () | ||
| 247 | "Check that Bug#25949 is fixed." | ||
| 248 | (skip-unless (executable-find "true")) | ||
| 249 | (should (eq (let ((default-directory "/:/")) (process-file "true")) 0)) | ||
| 250 | (should (processp (let ((default-directory "/:/")) | ||
| 251 | (start-file-process "foo" nil "true")))) | ||
| 252 | (should (eq (let ((default-directory "/:/")) (shell-command "true")) 0))) | ||
| 253 | |||
| 246 | (provide 'files-tests) | 254 | (provide 'files-tests) |
| 247 | ;;; files-tests.el ends here | 255 | ;;; files-tests.el ends here |