From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Allen Li Newsgroups: gmane.emacs.bugs Subject: bug#29465: 25.3; Confusing message for dired-do-shell-command substitution Date: Sun, 26 Nov 2017 23:34:33 -0800 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1511768118 11040 195.159.176.226 (27 Nov 2017 07:35:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 27 Nov 2017 07:35:18 +0000 (UTC) To: 29465@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Nov 27 08:35:13 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJDwa-0002Er-SC for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 Nov 2017 08:35:09 +0100 Original-Received: from localhost ([::1]:59530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJDwh-0007HI-VW for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 Nov 2017 02:35:15 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44037) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJDwY-0007HA-Uf for bug-gnu-emacs@gnu.org; Mon, 27 Nov 2017 02:35:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eJDwU-00077f-Ui for bug-gnu-emacs@gnu.org; Mon, 27 Nov 2017 02:35:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51288) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eJDwU-00077Z-Py for bug-gnu-emacs@gnu.org; Mon, 27 Nov 2017 02:35:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eJDwU-00084Y-I4 for bug-gnu-emacs@gnu.org; Mon, 27 Nov 2017 02:35:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Allen Li Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 Nov 2017 07:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29465 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 29465-submit@debbugs.gnu.org id=B29465.151176808130996 (code B ref 29465); Mon, 27 Nov 2017 07:35:02 +0000 Original-Received: (at 29465) by debbugs.gnu.org; 27 Nov 2017 07:34:41 +0000 Original-Received: from localhost ([127.0.0.1]:59969 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJDw9-00083q-6B for submit@debbugs.gnu.org; Mon, 27 Nov 2017 02:34:41 -0500 Original-Received: from mail-qt0-f169.google.com ([209.85.216.169]:38193) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJDw8-00083e-5p for 29465@debbugs.gnu.org; Mon, 27 Nov 2017 02:34:40 -0500 Original-Received: by mail-qt0-f169.google.com with SMTP id q13so26453638qtb.5 for <29465@debbugs.gnu.org>; Sun, 26 Nov 2017 23:34:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=/3470ZnFscklgfqHasFpdILIpmylb7oEleRK9YHGbso=; b=YIWxVCe2vhUL/Ju8Fk5nJSl3kTKe8rRsJxKZCCX/nwbfC0Y6MGxwjw5/TpXkffxlnr +/dxqFROcMo8xVw6jsjUMebjckKf9My3x4TaBUyZfKvuVZ26VaW59D7UxIxZE2HGo7I4 ROovkIYRXWw8UQ5g4WSWHEptH1HpHZZp0DGZfpBWmYEE0IC6Tc2WTGQhiqcZEi6R35b4 u2/Vc/FqP9ljKLVnGybAQnEQ7+vmzlsIoi6iZjBqxpr3p7MNdUrYIed1Hd1uYBvgZ3qJ zUDPEgV84P0+Luh7p4z4BoQTAEHmj1/k3dkKkGX2PJq02go/1fcqvnSUkaYF/EEBvYif ezUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=/3470ZnFscklgfqHasFpdILIpmylb7oEleRK9YHGbso=; b=G3bv1qftXeChBG/0C1iBjuOfWhtFVp1pVuJ6MBX0sMJ+k6YRhsFAmLPMdmkUKZlb3I srxwdsa6KO23EgWturbAkFbeYYjzwXSI5B5Cn3ucvAe8R8u6/lRrKIM2n2VZVa4PPKUB IRQexXrU3u8rpiUE7amGrh1zKA2qOuKHI+UITrok0zrwpmkpeR29MN6Y0QrBwfGOaASF LEtYU1RT6HSeqxEv78jrlfnc71Np6DpD7IcUULf4WBmQUE/jc4dEtLxHNFV4hs3zIsqW REg3oEDpR0cQt/o6PvjXpkcuJIh+dGLdjB/5uIsJlyZui3ndGUYQ/aRmuFwXXBcstwor nSMw== X-Gm-Message-State: AJaThX51B67T/RE9nTnTJKasaoJG1plG63n1r+C7LLysZ5XrVMUCTXo6 3QZRf79exvXtI4Jo1SgNKDXzOJSOj6LsW6NYVQhmn87A X-Google-Smtp-Source: AGs4zMZYhzLhUH4zGN3HBEQJ+n1on8PamTNyvkLt6e7n9VUiT0JNpN3A7/GC2zBM1E0tFSjrcpQwtxNllp1QQ2Bl8Io= X-Received: by 10.200.54.93 with SMTP id n29mr60148473qtb.179.1511768074315; Sun, 26 Nov 2017 23:34:34 -0800 (PST) Original-Received: by 10.237.52.161 with HTTP; Sun, 26 Nov 2017 23:34:33 -0800 (PST) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:140445 Archived-At: 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