Subject: bug#29465: 25.3; Confusing message for dired-do-shell-command substitution

From: Allen Li <[email-masked]>
Date: Sun, 26 Nov 2017 23:34:33 -0800

I have included two patches.  The first is to fix the documentation
string which I encountered while reading the code, the second is for
my proposed solution of removing the confirmation message.

Subject: [PATCH 1/2] Clarify dired-do-shell-command docstring

The docstring seemed to imply that if * and ? were used together, *
would take priority.  However, it is explicitly checked that * and ?
are not used together.

* lisp/dired-aux.el (dired-do-shell-command): Fix docstring
---
 lisp/dired-aux.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index f1f7cf0b0e..57eb216231 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -686,13 +686,15 @@ dired-do-shell-command
 If there is a `*' in COMMAND, surrounded by whitespace, this runs
 COMMAND just once with the entire file list substituted there.

-If there is no `*', but there is a `?' in COMMAND, surrounded by
-whitespace, or a `\\=`?\\=`' this runs COMMAND on each file
-individually with the file name substituted for `?' or `\\=`?\\=`'.
+If there is a `?' in COMMAND, surrounded by whitespace, or a
+`\\=`?\\=`' this runs COMMAND on each file individually with the
+file name substituted for `?' or `\\=`?\\=`'.

 Otherwise, this runs COMMAND on each file individually with the
 file name added at the end of COMMAND (separated by a space).

+`*' and `?' cannot be used together.
+
 `*' and `?' when not surrounded by whitespace nor `\\=`' have no special
 significance for `dired-do-shell-command', and are passed through
 normally to the shell, but you must confirm first.
-- 
2.15.0

Subject: [PATCH 2/2] Remove confirmation when using * or ? for the shell

These confirmation messages are misleading, do not trigger for all
cases, and obstruct many commands that use * or ?, like find, sed,
grep, etc.

* lisp/dired-aux.el (dired-do-shell-command): Remove substitution mark
  confirmation
---
 lisp/dired-aux.el | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 57eb216231..15bb3173b7 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -744,20 +744,10 @@ dired-do-shell-command
                            (dired--star-or-qmark-p res str))
                  (setq res (replace-match "" t t res 2)))
                (string-match regexp res))))
-  (let* ((on-each (not (dired--star-or-qmark-p command "*" 'keep)))
- (no-subst (not (dired--star-or-qmark-p command "?" 'keep)))
-         ;; Get confirmation for wildcards that may have been meant
-         ;; to control substitution of a file name or the file name list.
-         (ok (cond ((not (or on-each no-subst))
-             (error "You can not combine `*' and `?' substitution marks"))
-            ((need-confirm-p command "*")
-             (y-or-n-p (format-message
-        "Confirm--do you mean to use `*' as a wildcard? ")))
-            ((need-confirm-p command "?")
-             (y-or-n-p (format-message
-        "Confirm--do you mean to use `?' as a wildcard? ")))
-            (t))))
-    (when ok
+    (let* ((on-each (not (dired--star-or-qmark-p command "*" 'keep)))
+           (no-subst (not (dired--star-or-qmark-p command "?" 'keep))))
+      (unless (or on-each no-subst)
+        (error "You can not combine `*' and `?' substitution marks"))
       (if on-each
    (dired-bunch-files (- 10000 (length command))
                       (lambda (&rest files)
@@ -766,7 +756,7 @@ dired-do-shell-command
                       nil file-list)
  ;; execute the shell command
  (dired-run-shell-command
- (dired-shell-stuff-it command file-list nil arg)))))))
+ (dired-shell-stuff-it command file-list nil arg))))))

 ;; Might use {,} for bash or csh:
 (defvar dired-mark-prefix ""
-- 
2.15.0