diff options
| author | Tino Calancha | 2017-07-03 12:55:06 +0900 |
|---|---|---|
| committer | Tino Calancha | 2017-07-03 12:55:06 +0900 |
| commit | bc3dcd524dfb5c889ed017c093eaf028596fc35c (patch) | |
| tree | f1c783db64e4b97127902888f71360071aa5e946 | |
| parent | 1b4f0a92ff3505ef9a465b9b391756e3a73a6443 (diff) | |
| download | emacs-bc3dcd524dfb5c889ed017c093eaf028596fc35c.tar.gz emacs-bc3dcd524dfb5c889ed017c093eaf028596fc35c.zip | |
dired-do-shell-command: Fix check for wildcards
* lisp/dired-aux.el (dired-do-shell-command): Replace just '?', '*'
and '`?' i.e., keep the whitespaces.
* test/lisp/dired-aux-tests.el (dired-test-bug27496): Add test.
| -rw-r--r-- | lisp/dired-aux.el | 2 | ||||
| -rw-r--r-- | test/lisp/dired-aux-tests.el | 44 |
2 files changed, 45 insertions, 1 deletions
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 12a97f8457e..e4547758587 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el | |||
| @@ -738,7 +738,7 @@ can be produced by `dired-get-marked-files', for example." | |||
| 738 | ;; Drop all ? and * surrounded by spaces and `?`. | 738 | ;; Drop all ? and * surrounded by spaces and `?`. |
| 739 | (while (and (string-match regexp res) | 739 | (while (and (string-match regexp res) |
| 740 | (dired--star-or-qmark-p res str)) | 740 | (dired--star-or-qmark-p res str)) |
| 741 | (setq res (replace-match "" t t res 0))) | 741 | (setq res (replace-match "" t t res 2))) |
| 742 | (string-match regexp res)))) | 742 | (string-match regexp res)))) |
| 743 | (let* ((on-each (not (dired--star-or-qmark-p command "*" 'keep))) | 743 | (let* ((on-each (not (dired--star-or-qmark-p command "*" 'keep))) |
| 744 | (no-subst (not (dired--star-or-qmark-p command "?" 'keep))) | 744 | (no-subst (not (dired--star-or-qmark-p command "?" 'keep))) |
diff --git a/test/lisp/dired-aux-tests.el b/test/lisp/dired-aux-tests.el new file mode 100644 index 00000000000..9e02af272b6 --- /dev/null +++ b/test/lisp/dired-aux-tests.el | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | ;;; dired-aux-tests.el --- Test suite for dired-aux. -*- lexical-binding: t -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2017 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 10 | ;; (at your option) any later version. | ||
| 11 | |||
| 12 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ;; GNU General Public License for more details. | ||
| 16 | |||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | |||
| 20 | ;;; Code: | ||
| 21 | (require 'ert) | ||
| 22 | (require 'dired-aux) | ||
| 23 | |||
| 24 | |||
| 25 | (ert-deftest dired-test-bug27496 () | ||
| 26 | "Test for http://debbugs.gnu.org/27496 ." | ||
| 27 | (skip-unless (executable-find shell-file-name)) | ||
| 28 | (let* ((foo (make-temp-file "foo")) | ||
| 29 | (files (list foo))) | ||
| 30 | (unwind-protect | ||
| 31 | (cl-letf (((symbol-function 'y-or-n-p) 'error)) | ||
| 32 | (dired temporary-file-directory) | ||
| 33 | (dired-goto-file foo) | ||
| 34 | ;; `dired-do-shell-command' returns nil on success. | ||
| 35 | (should-error (dired-do-shell-command "ls ? ./?" nil files)) | ||
| 36 | (should-error (dired-do-shell-command "ls ./? ?" nil files)) | ||
| 37 | (should-not (dired-do-shell-command "ls ? ?" nil files)) | ||
| 38 | (should-error (dired-do-shell-command "ls * ./*" nil files)) | ||
| 39 | (should-not (dired-do-shell-command "ls * *" nil files)) | ||
| 40 | (should-not (dired-do-shell-command "ls ? ./`?`" nil files))) | ||
| 41 | (delete-file foo)))) | ||
| 42 | |||
| 43 | (provide 'dired-aux-tests) | ||
| 44 | ;; dired-aux-tests.el ends here | ||