From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Boruch Baum Newsgroups: gmane.emacs.bugs Subject: bug#48072: 28.0.50: dired-read-shell-command: handle empty input properly [PATCH] Date: Tue, 27 Apr 2021 15:02:43 -0400 Message-ID: <20210427190243.n5yg3gywd5wma3jl@E15-2016.optimum.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="mhgi27fezbpzjmsj" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15275"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: NeoMutt/20180716 To: 48072@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 27 21:03:13 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lbSzH-0003ie-5A for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 27 Apr 2021 21:03:11 +0200 Original-Received: from localhost ([::1]:47056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lbSzG-0006LT-75 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 27 Apr 2021 15:03:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbSz8-0006L2-Qw for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2021 15:03:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39383) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lbSz8-0002BA-J3 for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2021 15:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lbSz8-000554-Ba for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2021 15:03:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Boruch Baum Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 27 Apr 2021 19:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 48072 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: Emacs Bug Reporting Original-Received: via spool by submit@debbugs.gnu.org id=B.161955017519514 (code B ref -1); Tue, 27 Apr 2021 19:03:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 27 Apr 2021 19:02:55 +0000 Original-Received: from localhost ([127.0.0.1]:50929 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lbSz1-00054g-Gw for submit@debbugs.gnu.org; Tue, 27 Apr 2021 15:02:55 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:48252) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lbSyx-00054W-FD for submit@debbugs.gnu.org; Tue, 27 Apr 2021 15:02:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbSyw-0006Ab-Ur for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2021 15:02:51 -0400 Original-Received: from mout.gmx.net ([212.227.17.20]:45629) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbSyu-00020k-Iz for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2021 15:02:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1619550166; bh=ESKMd+CU0JQ4BoHIz+SxOG9vyBNKdOx3jtCWdyHC/40=; h=X-UI-Sender-Class:Date:From:To:Subject; b=iorK+I84qPAmria+pEXyABL3SNMD8lMt6kbSBkjVQd8im5oUx+kvfG62k7em/w+jI 2ay7h80aH5l4MSTMn+7cX15Zf+YIMqQFLWhTHFw+ObrRNpH6KJEX9X8ehOREKPuUxO wdH2rHMpfoO0/7Hz/ZwNpl3A9e4G46xMWK++CNoY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from E15-2016.optimum.net ([70.19.86.82]) by mail.gmx.net (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MmDEm-1lBEus0Rwe-00iAfT for ; Tue, 27 Apr 2021 21:02:46 +0200 Content-Disposition: inline X-Provags-ID: V03:K1:AwOW+QHyqYojSk/1ei71t1ebIVNtyEdeS5A/o4Da/y8x/FW7wFv b0WroEvb5ffSAZiQchyGOIabZZ4rYQjI3BiOEI8Eo76fof0owMCQFuW9soLH2quNOqQJq/p 4nIDqR/138rIjw61PmqMAQv4uMbQYqsYjKQKITIzO5fW0oKZIis8dJbNLFuGn4MKogp+H4v oN8lcC9K7gfDMkq7/ItYA== X-UI-Out-Filterresults: notjunk:1;V03:K0:L06RcBppdJU=:Do097oJ3MBcHPRmKfyt0nS qhgGP3AWtvAxJGkntrALykPJQgMH2BduMdCkHNSl+rISisfdl4LcE8rKMI7fsaoUzQPij+eIg XqZTJBSjMybIhUbgBlpk2A/vErvU0IN+YOzxo2W2ueBAZ5VdPUrliq+A+P6Bn4xGKOs5zKO4G EpKL1BSLPzo7Edlt+8wkG2d4BGYnpTydPd55O9KZyffFK6PgnHdeSqGAkpTIvIXKh671TCcQ9 17Q2fJurZPLoOkg5N9b1DWiT258zbZ4hSLIlS2Zb5R2u2l9hRmFSQprFZWh9XQXWRltPCeKY8 0Mzq6xiyOPQ8lSMvDuVHHMDHJTiB5pDXhlHs4+N9qjMzosO8LrDkEyjGijK3vfqJuav7I8t1x 3nqUxjQ6L1erAtHVsIeE8yckydLSqVy0cUJwrwCFL4l08NUBV5Ffg9LHtW5IyoDV4mwDZfPOn cstoPJNQ+W5ReBmvAnXUb33lbx/BtUrLQybYCf7ectPwDW9RddP9zZceDK0IlJ9wH0OKYkaQb pR9CGk4oUF9eg3+OlazvujpZFDDoj2kodWg5VLu6dtWLckbhFRCjjqAKikoi2DB4DX8JeOyN/ Wj/ralugd7BowXSjy6mZGiZeA8dCtsszsOTRjSvpGUtPuZpiIS+XEcuLWY+leTtfVfOStxwBR iFyde1lE9TaQ2zdFqEtTFkTxaW5s4wZq7zYZxheae5xowD63dlpIwAbzUjXUGMrGFXcq24TCX v5LSc1ZCg+nU05YuhPNLf9yxOAV31RAcKBuRK2VyDwm63+U9NgGSySHTK7ddC5cDj19Kr345 Received-SPF: pass client-ip=212.227.17.20; envelope-from=boruch_baum@gmx.com; helo=mout.gmx.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:205046 Archived-At: --mhgi27fezbpzjmsj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Function dired-read-shell-command was accepting an empty input. This is a bug because it then passes the empty input as a legitimate command which is silently processed (in error) by dired, eventually to return a completion message. The attached patch fixes that, and also validates the entered command as a valid shell executable. =2D- hkp://keys.gnupg.net CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0 --mhgi27fezbpzjmsj Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="dired-aux-read-shell-command.patch" Content-Transfer-Encoding: quoted-printable diff --git a/dired-aux.el b/dired-aux.el index 1c10990..7f5775c 100644 =2D-- a/dired-aux.el +++ b/dired-aux.el @@ -674,15 +674,22 @@ This normally reads using `read-shell-command', but = if the offer a smarter default choice of shell command." (minibuffer-with-setup-hook (lambda () - (setq-local dired-aux-files files) - (setq-local minibuffer-default-add-function - #'minibuffer-default-add-dired-shell-commands)) + (setq-local dired-aux-files files) + (setq-local minibuffer-default-add-function + #'minibuffer-default-add-dired-shell-commands)) (setq prompt (format prompt (dired-mark-prompt arg files))) - (if (functionp 'dired-guess-shell-command) - (dired-mark-pop-up nil 'shell files - 'dired-guess-shell-command prompt files) - (dired-mark-pop-up nil 'shell files - 'read-shell-command prompt nil nil)))) + (let (command) + (setq command + (if (functionp 'dired-guess-shell-command) + (dired-mark-pop-up nil 'shell files + 'dired-guess-shell-command prompt files) + (dired-mark-pop-up nil 'shell files + 'read-shell-command prompt nil nil))) + (when (string-empty-p command) + (user-error "No command entered. Nothing to do!")) + (unless (executable-find command) + (user-error "Not a valid command!")) + command))) ;;;###autoload (defun dired-do-async-shell-command (command &optional arg file-list) --mhgi27fezbpzjmsj--